-
Notifications
You must be signed in to change notification settings - Fork 303
feat(python-sdk): support omitting username/password from basic auth when configured in IR #14407
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
base: main
Are you sure you want to change the base?
Changes from all commits
97ba837
a3f8635
e388f2c
5167926
1d56f47
af66447
d447854
f0f03d5
55b8f55
0e7aed7
b68310c
dea51d2
b85372b
e42b9fe
87deef3
dd520ad
b2e22fd
406c776
96607ee
ad58c5a
282e654
146db63
2a813d7
40088a3
dfe72db
47467b8
4ab97bf
e6132b5
904bd20
191e55f
57a4e42
b199044
7eb55d3
414980d
b1e6b89
b43fb7c
cfd5582
27311c2
32c911e
0d88056
fa01ae5
b5a83aa
34b9a30
79d4246
8cd9896
629447a
140db1e
2a25ce8
04718e3
cbd7f5e
ad61f74
b1ca1bd
b82592a
c83989d
db6f0d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,16 +293,24 @@ export class EndpointSnippetGenerator { | |
| auth: FernIr.dynamic.BasicAuth; | ||
| values: FernIr.dynamic.BasicAuthValues; | ||
| }): python.NamedValue[] { | ||
| return [ | ||
| { | ||
| // usernameOmit/passwordOmit may exist in newer IR versions | ||
| const authRecord = auth as unknown as Record<string, unknown>; | ||
| const usernameOmitted = !!authRecord.usernameOmit; | ||
| const passwordOmitted = !!authRecord.passwordOmit; | ||
|
Comment on lines
+297
to
+299
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 CLAUDE.md violation: CLAUDE.md explicitly states: "Never use Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| const args: python.NamedValue[] = []; | ||
| if (!usernameOmitted) { | ||
| args.push({ | ||
| name: this.context.getPropertyName(auth.username), | ||
| value: python.TypeInstantiation.str(values.username) | ||
| }, | ||
| { | ||
| }); | ||
| } | ||
| if (!passwordOmitted) { | ||
| args.push({ | ||
| name: this.context.getPropertyName(auth.password), | ||
| value: python.TypeInstantiation.str(values.password) | ||
| } | ||
| ]; | ||
| }); | ||
| } | ||
| return args; | ||
| } | ||
|
|
||
| private getConstructorBearerAuthArgs({ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴
as unknown as Record<string, unknown>violates CLAUDE.md rule and relies on fragile data smugglingCLAUDE.md explicitly prohibits
as unknown as Xtype assertions: "Never useas anyoras unknown as X. These are escape hatches that bypass the type system entirely. If the types don't line up, fix the types."Beyond the rule violation, this pattern exists because
usernameOmit/passwordOmitare smuggled as extra properties on aDynamicSnippets.BasicAuthobject (which only definesusernameandpasswordperpackages/ir-sdk/src/sdk/api/resources/dynamic/resources/auth/types/BasicAuth.ts:5-8). The converter atpackages/cli/generation/ir-generator/src/dynamic-snippets/DynamicSnippetsConverter.ts:736-749attaches these as ad-hoc properties, relying on JavaScript spread to propagate them. If the dynamic snippet IR passes through any schema-based serialization/deserialization boundary (as is typical when IR is passed to generators via JSON), these undeclared fields may be silently stripped, causing!!authRecord.usernameOmitto always evaluate tofalseand the feature to silently not work. The proper fix is to extend theDynamicSnippets.BasicAuthtype in the IR definition to include the new fields.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a known limitation. The
FernIr.dynamic.BasicAuthtype comes from@fern-fern/ir-sdk(the published IR SDK package), which doesn't have typedusernameOmit/passwordOmitfields yet. The fields exist in the IR schema (packages/ir-sdk/src/sdk/api/resources/auth/types/BasicAuthScheme.ts) but the dynamic IR types haven't been updated to include them. Updating the IR types is out of scope for this PR per maintainer instruction ("Fix the non-IR changes"). The cast is necessary until the published IR SDK is updated.