Repository navigation
fix(resources): fill path placeholders by param name, not position - #1068
Open
littlewoo-legora wants to merge 1 commit into
Open
littlewoo-legora wants to merge 1 commit into
littlewoo-legora wants to merge 1 commit into
Conversation
Twelve generated commands declare their path params in a different order from their path, so --flag and --environment (or --segment and --environment) were swapped in the request URL. Substitute each placeholder with the param of the same name, compared case-insensitively. Fixes launchdarkly#1067. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
littlewoo-legora
requested review from
btesfamariam
and removed request for
a team
December 2, 2026 10:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirements
Tested on macOS (arm64) with Go 1.27.3; not on other platforms.
Related issues
Fixes #1067.
Describe the solution you've provided
buildURLWithParamsfilled the{…}placeholders in a path by position, in the order of the command'sParamslist. Twelve generated commands declare their params in a different order from their path, so--flagand--environment(or--segmentand--environment) landed in each other's place.ldcli flags list-expiring-context-targets --flag my-flag --environment productionrequested/flags/<project>/production/expiring-targets/my-flag.makeRequestnow collects path params into a map keyed by the lower-cased camel-case param name.buildURLWithParamsreplaces each placeholder with the value of the same name, comparing case-insensitively sotrigger-idfills{triggerID}. Every one of the 399 generated commands has a path param for each placeholder by this rule, so commands that worked before build the same URLs.The empty-response branch, which reports the last path param as
{"key": …}, keeps using the last path param in declared order.MockClientnow records the request path, andTestPathParamsFillPlaceholdersByNamecovers a flag-then-environment path, a segment-then-environment path and a differently capitalised id placeholder. All three cases fail onmainwith the values swapped.go test ./...passes apart frominternal/symbols/r8indexTestGoldenIndexBytes, which fails the same way onmainwithout this change.go mod tidyleavesgo.modandgo.sumunchanged.Describe alternatives you've considered
Emitting
Paramsin path order from the generator. That fixes today's commands, but substitution would still depend on position, so a new endpoint could bring the bug back.Additional context
Found while scheduling removal of an individual context target with
update-expiring-targets. With the fix, the documented--flag/--environmentorder works against the live API.Note
Overview
Fixes incorrect API URLs when OpenAPI path parameter order does not match the generated command’s
Paramslist. Path segments were filled in declaration order instead of by placeholder name, so commands likeflags list-expiring-context-targetscould send--environmentand--flagvalues in each other’s slots.makeRequestnow stores path flag values in a map keyed by lower-cased camel-case names;buildURLWithParamsbinds each{placeholder}to the matching key with case-insensitive name comparison (e.g.--id→{triggerID}). Empty DELETE-style responses still synthesize{"key": …}from the last path param in declared order, not from positional substitution.MockClientrecords the request path for assertions.TestPathParamsFillPlaceholdersByNamecovers flag/environment, segment/environment, and mixed-case id placeholder cases that fail onmain.Reviewed by Cursor Bugbot for commit ef26219. Bugbot is set up for automated code reviews on this repo. Configure here.