fix(importer-postman): stop swapping the API key name and its value - #643
Merged
gschier merged 1 commit intoSep 12, 2026
Merged
Conversation
Postman's apikey auth array flattens to { key, value, in } where key is the
header or query-parameter name and value is the secret -- the same meaning
Yaak's own apikey auth gives those fields. The importer assigned them
crosswise, so every imported request sent the secret as the parameter name
and the parameter name as the secret.
The blessed fixture hid it: its apikey block used key="key" and
value="value", so the swapped output still read plausibly. Give those
fields distinct values so the swap cannot come back unnoticed.
|
Thanks for the PR. This appears to match Yaak's contribution policy and is awaiting review by @gschier. This only means the PR is in scope for review. It does not mean the change has been reviewed or accepted for merge. |
|
gschier
approved these changes
Sep 12, 2026
gschier
left a comment
Member
There was a problem hiding this comment.
Nice catch. Thanks for the fix!
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.
Summary
The Postman importer assigns API Key auth crosswise, so an imported request sends the secret as the header name and the header name as the secret. Restore the identity mapping and make the fixture non-degenerate so the swap cannot hide again.
Submission
CONTRIBUTING.md.Detail
pmArrayToObjkeys Postman's array by the parameter name:so for a Postman apikey block,
a.keyis the header/query parameter name anda.valueis the secret.importAuththen reverses them:That is the opposite of what the field means everywhere else.
auth-apikeylabelskeyas "Header Name" / "Parameter Name" andvalueas "API Key" withpassword: true, and applies them assetHeaders: [{ name: key, value }]. The sibling branches in this same function —basic,bearer,awsv4— all map straight across;apikeyis the only one that crosses.A collection importing
X-API-Key: secret-123therefore produces a request that sendssecret-123: X-API-Key. It fails with 401/403, and because the masking follows the field rather than the content, the secret ends up displayed in the plaintext "Key" box while the harmless header name sits behind the password mask.Why the tests did not catch it
auth.input.jsonused the degenerate valueskey="key"andvalue="value", so the swapped output read{"key": "value", "value": "key"}— which looks plausible enough to bless. This PR changes them toX-API-Keyandsecret-123.Test plan
convertPostmanand compared against their.output.jsonexactly astests/index.test.tsdoes → all three match.auth.input.jsonwith"key": "secret-123"where"key": "X-API-Key"is expected.