Skip to content

fix: encode resource identifiers as URL path segments - #422

Open
bm1016bm-svg wants to merge 1 commit into
getlago:mainfrom
bm1016bm-svg:fix/encode-resource-identifiers
Open

bm1016bm-svg wants to merge 1 commit into
getlago:mainfrom
bm1016bm-svg:fix/encode-resource-identifiers

Conversation

@bm1016bm-svg

Copy link
Copy Markdown

client.customers.find("customer#billing") currently builds a URL whose fragment is billing, so the HTTP request targets customer instead of the supplied external ID. Question marks become query strings, slashes create extra path segments, and literal percent escapes are reinterpreted. The shared URL builder affects both standard and nested resource methods.

Encode each raw path_parts element separately before joining it, leaving query serialization unchanged. Also escape standalone . and .., which quote() otherwise preserves and urljoin normalizes away. Callers supply raw identifiers, including literal % characters, rather than pre-encoded URLs.

Validation:

  • The initial regression set fails against the unmodified implementation: eight URL-builder cases and four public customer lookup cases. HTTPX mock teardown also reports the four expected requests were never sent.
  • Final full suite: python -m pytest -q — 463 passed (three existing deprecation warnings), Python 3.12, HTTPX 0.28.1.
  • Tests assert the actual HTTPX request's raw_path and authorization header for reserved characters and dot-segment identifiers, plus nested paths and independently encoded query parameters. No live Lago API or customer data is used.
  • Ruff lint and formatting checks on changed files; git diff --check.

This is separate from #410 / #421, which address missing authorization on child-resource listings.

Implemented and tested with OpenAI Codex assistance.

@cla-check-bot

cla-check-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

Welcome, @bm1016bm-svg!

Thanks for your first contribution!

Before we proceed with the review, please sign the Fiduciary License Agreement:

Sign the FLA

Once signed, this PR will be automatically updated.

@cla-check-bot

cla-check-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

Thanks, @bm1016bm-svg! 🎉

Your CLA has been signed and is now on file. We'll proceed with the review shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant