feat(csharp-sdk): remove omitted basic auth fields from SDK API, use empty string internally#14409
feat(csharp-sdk): remove omitted basic auth fields from SDK API, use empty string internally#14409Swimburger wants to merge 10 commits intomainfrom
Conversation
…en configured in IR Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
…y instead of coarse eitherOmitted flag Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
| const usernameOmitted = basicScheme.usernameOmit === true; | ||
| const passwordOmitted = basicScheme.passwordOmit === true; | ||
| // Per-field condition: required fields must be present, omittable fields are always satisfied | ||
| let condition: string; | ||
| if (!usernameOmitted && !passwordOmitted) { | ||
| condition = `${usernameAccess} != null && ${passwordAccess} != null`; | ||
| } else if (usernameOmitted && passwordOmitted) { | ||
| condition = `${usernameAccess} != null || ${passwordAccess} != null`; | ||
| } else if (usernameOmitted) { | ||
| condition = `${passwordAccess} != null`; | ||
| } else { | ||
| condition = `${usernameAccess} != null`; | ||
| } |
There was a problem hiding this comment.
Logic bug: When both username and password are optional (usernameOmit and passwordOmit are both true), but auth itself is required (isAuthOptional = false) and there's only one basic scheme, no condition check is generated. This causes the Authorization header to always be set with "" (empty credentials) even when both username and password are null, contradicting the changelog which states the header should be omitted when neither credential is provided.
Fix: The condition logic needs to account for the case where fields are optional even when isAuthOptional is false. When either field is omitted, a condition check should still be generated:
const eitherOmitted = usernameOmitted || passwordOmitted;
if (isAuthOptional || basicSchemes.length > 1 || eitherOmitted) {
const controlFlowKeyword = i === 0 ? "if" : "else if";
innerWriter.controlFlow(controlFlowKeyword, this.csharp.codeblock(condition));
}Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
… per-field omit fix Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ms, use empty string internally Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…(attempt 3) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…(attempt 4) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Description
Refs #14378
When
usernameOmitorpasswordOmitflags are set in the IR'sBasicAuthScheme, the generated C# SDK now completely removes the flagged field from the constructor and client options — it does not appear in the end-user API at all. Internally, the omitted field is treated as an empty string when encoding theAuthorization: Basicheader (e.g.password: omit: true→ header encodesusername:). Default behavior (both required) is preserved when no omit flags are set.Split from #14378 (one PR per generator).
Changes Made
RootClientGenerator.ts:basicScheme.usernameOmit/basicScheme.passwordOmitas independent booleansparamsarray (not just made optional). Only non-omitted fields appear in the generated constructor.""directly in the Base64 interpolation (e.g.$"{""}:{password}"when username is omitted), instead of a null-coalescing fallback on a parameter that no longer exists.passwordOmitis set, condition isusername != null)versions.yml: new 2.55.4 entrybasic-auth-optionaltest fixture withpassword: omit: true, plus seed output atseed/csharp-sdk/basic-auth-optional/Updates since last revision
""in the auth header encodingseed-test-results (csharp-sdk)cancellations (infrastructure issue, not code-related)Testing
basic-auth-optionalfixturebiome check)SeedBasicAuthOptionalClient.csstill showspasswordas an optional constructor parameter withpassword ?? ""null-coalescing. This appears to have been generated before the field-removal changes were applied to the generator. CI should regenerate this — verify after CI passes that the generated constructor no longer includes the omittedpasswordfield and uses a bare""instead.RootClientGenerator.ts): Confirm thatif (!usernameOmitted)/if (!passwordOmitted)correctly excludes the field fromparamsentirely, and that the returned array only contains non-omitted fields.""(literal empty string), not a reference to a now-nonexistent parameter. Check thatusernameExpr/passwordExprare correct."true"(always set the header with"":""encodingOg==). Confirm this is the desired behavior.Link to Devin session: https://app.devin.ai/sessions/0786b963284f4799acb409d5373cde0a
Requested by: @Swimburger