fix(cli): do not pass the github token to generators in preview mode - #17425
fix(cli): do not pass the github token to generators in preview mode#17425fern-api[bot] wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
AI Review Summary
Small, well-scoped CLI fix: preview runs no longer forward the (empty-substituted) GitHub token into the IR publishing config, avoiding a doomed clone inside the generator container. Logic and threading look correct; only minor robustness/test nits.
- 🔵 2 suggestion(s)
| const mockContext = { | ||
| logger: { | ||
| debug: () => undefined, | ||
| warn: () => undefined | ||
| } | ||
| // Test mock: getPublishConfig only touches the logger. | ||
| } as unknown as TaskContext; |
There was a problem hiding this comment.
🔵 suggestion
The logger stub only implements debug/warn. If getPublishConfig ever logs at another level (or calls context.failAndThrow), the test explodes with an unhelpful is not a function. Cheap insurance: stub info/error/log too, or use a Proxy returning no-ops.
There was a problem hiding this comment.
Good call — done in 0cedfc0: the stub logger is now a Proxy returning no-ops for every level, so a new log call can't blow the test up with is not a function. Still green: pnpm turbo run test --filter @fern-api/local-workspace-runner (182 passed).
Docs Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on
Docs generation runs |
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Summary
Two related fixes for README/reference generation killing otherwise-successful SDK generation (Auth0, Pylon #22738).
1. CLI, preview-scoped (
runLocalGenerationForWorkspace.ts):--previewsubstitutes env vars as empty strings, sogithub.token: ${GITHUB_TOKEN}reaches the IR as"".AbstractGeneratorAgent.getRemoteonly null-checks, so the generator builds a readme remote and does an unauthenticatedgit clonein the container.getPublishConfignow takesisPreviewand omits the token only when it is actually unusable:A preview run with a real token still forwards it (full-fidelity README). When the token is dropped, a
logger.warnsays README/reference content won't be merged from the existing repo. Non-preview behavior is unchanged — an empty token is still passed through as-is.2. Generators, non-fatal README/reference (
generators/base/src/AbstractGeneratorAgent.ts): this also bites non-preview runs where the token is forwarded but the in-container clone fails on a corporate TLS-interception CA.generateReadme/generateReferencepreviously logged at debug and rethrew, killing generation before any SDK files were copied (.fernignorecleanup then left a PR with only custom files + changelog). They now returnstring | undefinedand never throw:remote: undefined(generates the README from scratch instead of merging the repo's existing one), with alogger.warnnaming the underlying error.logger.warn(never debug-only) including the underlying reason, and skip emitting that file.SwiftGeneratorAgentoverrides both methods, so it got the same treatment. All call sites (csharp,go-v2,java-v2,php,python-v2,ruby-v2,rust,swift,typescript) skip emitting the file when the content isundefined.Testing
pnpm turbo run test --filter @fern-api/local-workspace-runner— 185 passed.getPublishConfig.preview.test.tscovers empty/absent token in preview → omitted, non-empty token in preview → forwarded, and both token cases outside preview → forwarded unchanged.pnpm compile— full monorepo compile green.Changelog
packages/cli/cli/changes/unreleased/fix-preview-github-token.ymlfix-readme-generation-non-fatal.ymlunder each affected generator'ssdk/changes/unreleased/(csharp, go, java, php, python, ruby-v2, rust, swift, typescript).