fix(cli): register two-field basic auth at root so auth status lists it [FER-11474]#16761
Open
fern-support wants to merge 2 commits into
Open
Conversation
…s it [FER-11474] Generated CLIs wired standard HTTP Basic via `.auth_basic_scheme(...)` on the OpenApiBinding (binding-level), but the framework `auth` subcommand only reads app-level auth bindings. Result: `<bin> auth status` printed "No auth schemes are declared" for basic-auth CLIs even though credentials flowed and requests authenticated correctly. Emit two-field basic via the root `BasicAuth` typed builder instead, matching how bearer and header schemes are already placed. The root builder lowers to the identical `SchemeBinding::Basic` and still propagates to the binding via `set_root_auth`, so request-time behavior is unchanged — this only makes the scheme visible to `auth status` (and the warn-only startup validation). The usernameOmit/passwordOmit custom-provider variants stay binding-level; no root path exists for `BasicAuthProvider`, so those configs are untouched.
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
Fixes FER-11474. Generated Fern CLIs whose auth resolves to standard two-field HTTP Basic report
No auth schemes are declaredfrom<bin> auth status, even though credentials are wired and requests authenticate correctly. This is cosmetic but confusing — it surfaced while a prospect evaluated the Mailchimp CLI.Root cause
There are two
auth_bindingsregistries infern-cli-sdk:CliApp— populated by.auth(...). This is the only list the frameworkauthsubcommand reads (dispatch_auth(..., &self.auth_bindings, ...)→handle_status).OpenApiBinding— populated by.auth_basic_scheme(...).propagate_root_authpushes app-level auth down to bindings viaset_root_auth, but there is no reverse harvest, so binding-level schemes never reach the listauth statusreads.The generator's
detectAuth.tsplaced schemes accordingly:auth status?.auth(BearerAuth)).auth(ApiKeyAuth)).auth_basic_scheme)Basic was the one scheme not migrated to root when the auth-at-root architecture landed (fern
8c3588d9dec) — theBasicAuthroot builder existed and was unit-tested in cli-sdk (b4e773d), but no sample binary exercised it, so it was overlooked.Change
Emit two-field basic via the root
BasicAuthtyped builder:Why this is safe for existing users
BasicAuth::into_binding()lowers to the identicalSchemeBinding::Basic { username, password }variant as.auth_basic_scheme(...).set_root_authstill propagates root auth into every binding, so request-time credential resolution is unchanged byte-for-byte.auth status, and (b)validate_authruns for it — and that path warns, never errors.Explicitly out of scope
The
usernameOmit/passwordOmitcustom-provider variants (e.g. the Close "API-key-in-basic-slot" pattern) stay binding-level — there is no root path forBasicAuthProvider. Those configs see zero change and do not regress. Giving them accurateauth statusrequires a root provider path or a binding→app harvest, tracked separately.Testing
detectAuth.test.ts(12 passing) — asserts root placement +BasicAuthbuilder output for two-field basic.copySpecs/emitReadme/emitReference/generateAgentSkills(44 passing) — confirmsmain.rsrendering, README, and skills are unaffected.Recommended reviewer/CI check
The end-to-end seed repro from the ticket (builds + runs a real basic-auth CLI):
Expected after this change:
auth statuslists thebasicAuthscheme instead of "No auth schemes are declared."