feat(agent-bff): emit the OpenAPI document from a forest-bff openapi subcommand - #1811
Open
Tonours wants to merge 1 commit into
Open
Conversation
1 new issue
|
Tonours
force-pushed
the
feature/prd-886-openapi-static-document
branch
from
August 6, 2026 20:48
ece634c to
b11c332
Compare
Tonours
force-pushed
the
feature/prd-887-openapi-cli-export
branch
2 times, most recently
from
August 6, 2026 20:59
1542743 to
92ca6d4
Compare
Tonours
force-pushed
the
feature/prd-887-openapi-cli-export
branch
from
August 6, 2026 21:01
92ca6d4 to
4312e31
Compare
Comment on lines
+26
to
+27
| `forest-bff --help` and `forest-bff --version` print to stdout and exit 0. Any other | ||
| argument exits 1 with the reason on stderr. |
There was a problem hiding this comment.
🟢 Low agent-bff/README.md:26
The README states that --help and --version print to stdout and exit 0 and that any other argument exits 1, but the CLI also accepts -h and -v as aliases that print to stdout and exit 0. Passing -h or -v is covered by the "any other argument exits 1" claim, so the documented behavior contradicts the actual behavior. Consider documenting -h and -v as accepted aliases.
Suggested change
| `forest-bff --help` and `forest-bff --version` print to stdout and exit 0. Any other | |
| argument exits 1 with the reason on stderr. | |
| `forest-bff --help`/`-h` and `forest-bff --version`/`-v` print to stdout and exit 0. Any other | |
| argument exits 1 with the reason on stderr. |
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/agent-bff/README.md around lines 26-27:
The README states that `--help` and `--version` print to stdout and exit 0 and that any other argument exits 1, but the CLI also accepts `-h` and `-v` as aliases that print to stdout and exit 0. Passing `-h` or `-v` is covered by the "any other argument exits 1" claim, so the documented behavior contradicts the actual behavior. Consider documenting `-h` and `-v` as accepted aliases.
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.
Stacked on #1810 (
feature/prd-886-openapi-static-document), which is itself stacked on #1809. The base is #1810's branch, notmain: both parents must be reviewed and merged first, in order (#1809, then #1810, then this). The diff below is only this branch's commit.Adds
forest-bff openapi: writes the OpenAPI document to stdout without booting the server.fixes PRD-887
Why a CLI at all
GET /agent/openapi.jsonis auth-gated, so a CI job, a codegen step, or a client dev without credentials has no HTTP path to the document. The CLI is that path. It needs no configuration, so it runs in a pipeline with no secrets:forest-bff openapi > openapi.jsonBehavior change on the packaged bin
Worth a look before merge. Previously
forest-bff <anything>ignored argv and booted the server. Now argv is parsed:forest-bffforest-bff openapiforest-bff --help/-hforest-bff --version/-vforest-bff openapi extraforest-bff bogus--helpand--versionfollow POSIX: a help request is not an error, so they print to stdout and exit 0. Failures print the reason on stderr with a one-line pointer to--helprather than dumping the whole usage.A deployment that passed a stray flag and silently got a server will now fail on upgrade. The repo's own
startscripts pass no arguments.Scope and safety
The no-argv path is untouched: same
runCli, same config parsing, same middleware chain. The export path never callsparseConfig, never constructs a logger, never binds a socket.Hand-rolled argv switch in its own
cli-dispatch.ts(74 lines), no arg-parsing dependency.cli-core.tsdrops to 245 lines.Stdout purity
An export piped to a file must contain only the document. This is easy to break silently:
createConsoleLoggersendsInfotoconsole.info, which writes to stdout, not stderr. Any future log on the export path would corrupt every pipe without failing anything.Verified byte-exactly rather than assumed: stdout is 48327 bytes, the serialized document is 48327 bytes. A test pins one single
process.stdout.writecall and assertsconsole.infois never reached.How to test
Ran on this branch: 793 tests pass (777 before, 16 added), lint and build clean.
An end-to-end pass covered the export with an empty environment (exit 0, document on stdout, stderr empty), the listener count before and after the export (unchanged, so nothing bound), the unknown-subcommand exit code with empty stdout, redocly validation of the exported document, the no-argv boot, and byte equality between the CLI export and the body the route serves, and the four POSIX flags. 14 checks, all passing.
Known limitations
DispatchOutcome.exitCodeis typednumberand the type admits{exitCode: 1, server}, a combination the code never produces. Harmless today since the only consumer readsexitCodealone.Definition of Done
General
Security