-
Notifications
You must be signed in to change notification settings - Fork 125
fix: handle clientContextParam collisions with builtin config keys #1788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
947c39f
fix: nest conflicting endpoint parameters
smilkuri d28b53f
fix: add fallback resolution
smilkuri 1edcd1e
chore: fix formatting and add changeset
smilkuri 7da325b
chore: address comments and add diff for build generate-protocol-tests
smilkuri 8fb3ddc
fix: add isClientContextParam flag to handle parameter types
smilkuri 04fe9a0
chore: refactor code and add custom ruleset
smilkuri d234258
chore: make code cleaner
smilkuri 880ecdd
chore: fix failing integ tests
smilkuri 05aa8c7
chore: format protocol tests
smilkuri 943e965
fix: update clientContextParamDefaults to only have conflicting params
smilkuri be513b1
chore: fix formatting and type imports
smilkuri 596c0a3
chore: rebase
smilkuri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@smithy/middleware-endpoint": minor | ||
| --- | ||
|
|
||
| handle clientContextParam collisions with builtin config keys | ||
41 changes: 41 additions & 0 deletions
41
packages/eventstream-serde-universal/src/clientContextParams-precedence.integ.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { describe, expect, test as it } from "vitest"; | ||
| import { XYZService } from "xyz"; | ||
|
|
||
| describe("client context parameters precedence integration test", () => { | ||
| it("should handle conflicting vs non-conflicting parameter precedence correctly", async () => { | ||
| // For non-conflicting params | ||
|
siddsriv marked this conversation as resolved.
|
||
| const clientWithNonConflicting = new XYZService({ | ||
| endpoint: "https://localhost", | ||
| apiKey: async () => ({ apiKey: "test-key" }), | ||
| customParam: "user-custom-value", | ||
| clientContextParams: { | ||
| apiKey: "test-key", | ||
| customParam: "nested-custom-value", | ||
| }, | ||
| }); | ||
|
|
||
| // Verify that endpoint resolution uses the nested value over root value | ||
| const resolvedConfig = clientWithNonConflicting.config; | ||
| const effectiveCustomParam = resolvedConfig.clientContextParams?.customParam ?? resolvedConfig.customParam; | ||
| expect(effectiveCustomParam).toBe("nested-custom-value"); | ||
|
|
||
| // For conflicting parameters | ||
| const clientWithConflicting = new XYZService({ | ||
| endpoint: "https://localhost", | ||
| apiKey: async () => ({ apiKey: "auth-key" }), | ||
| clientContextParams: { | ||
| apiKey: "endpoint-key", | ||
| }, | ||
| }); | ||
|
|
||
| // Verify that both auth and endpoint contexts can coexist | ||
| const resolvedConfigConflicting = clientWithConflicting.config; | ||
|
|
||
| // Verify endpoint context has the nested value | ||
| expect(resolvedConfigConflicting.clientContextParams?.apiKey).toBe("endpoint-key"); | ||
|
|
||
| // Verify auth context has the auth provider | ||
| const authIdentity = await resolvedConfigConflicting.apiKey?.(); | ||
| expect(authIdentity?.apiKey).toBe("auth-key"); | ||
| }); | ||
| }); | ||
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.