Skip to content

lib-cloudinfo: escape path parameters and share request code in CloudInfoClient #136

Closed

Description

@jordeu

Abstract

Follow-up from the review of #131. CloudInfoClient builds four requests by hand, and none of them escapes the values it puts in the URL path. A stray character in a provider or region can quietly request a different URL. The four copies of the request code have also already drifted apart. Fixing both in one place makes the client safer and easier to change.

Items

  • Escape path parameters. provider and region go into the URL path unescaped in getRegions, getProducts, getStoragePrices and getFamilies.
    • A region containing ? or # (e.g. us-east-1?x) makes URI.create read the rest as a query or fragment, so a different URL is requested.
    • A space throws IllegalArgumentException, which gets wrapped without a status.
    • Percent-encode each path segment (or reject invalid values up front).
  • Share the request code. Those four methods repeat the same steps: build, send, check the status, decode, wrap the exception. Timeouts, logging and error handling already differ between them (30s vs 60s). A private helper such as HttpResponse<String> get(String url, Duration timeout, String what), reusing apiError, would remove the duplication.

Refs: #131 review comments (pditommaso).

Activity

  1. added a commit that references this issue on Oct 1, 2026
    dfe6d1a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions