fix: read BACKLOG_PROJECT env var in document create, wiki create, and document view - #116
Open
sakai-classmethod wants to merge 3 commits into
Open
Conversation
The --project option of `document create` and `wiki create` was defined
with a plain .option() call, missing .env("BACKLOG_PROJECT"), while the
commands' help text advertised BACKLOG_PROJECT support via .envVars().
As a result, non-interactive runs (piped stdin or CI) failed with
"Project is required" even when BACKLOG_PROJECT was set, and interactive
runs showed an unnecessary prompt.
Wire the option to the environment variable using the same pattern as
`issue create`.
Claude-Session: https://claude.ai/code/session_01LoiedKxE7eSb6MFjNYApnn
The --project option of `document view` (required for --web) had the
same missing .env("BACKLOG_PROJECT") wiring as document create and
wiki create.
Claude-Session: https://claude.ai/code/session_01LoiedKxE7eSb6MFjNYApnn
_renderEnvVars() concatenated env vars auto-collected from Option.env() with the manually declared envVars() entries, so commands declaring BACKLOG_PROJECT in both places showed it twice in the ENVIRONMENT VARIABLES section. Deduplicate by variable name, letting the option-derived entry win. Claude-Session: https://claude.ai/code/session_01LoiedKxE7eSb6MFjNYApnn
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.
Fixes #115
Summary
document create,wiki create, anddocument viewdid not read theBACKLOG_PROJECTenvironment variable, even though their help text advertises it viaenvVars(). For the create commands, non-interactive runs (piped stdin or CI) failed with an error, and interactive runs showed an unnecessary prompt:For
document view,--webfailed withThe --project flag is required when using --web.under the same conditions.The
--projectoption of these commands was defined with a plain.option()call, missing.env("BACKLOG_PROJECT").envVars()only affects help rendering and does not wire the environment variable to the option.This PR wires the option to the environment variable using the same pattern as
issue create:It also fixes a related help-rendering issue:
_renderEnvVars()concatenated env vars auto-collected fromOption.env()with the manually declaredenvVars()entries, so commands declaringBACKLOG_PROJECTin both places (e.g.issue createand everyopt.project()user) listed it twice in the ENVIRONMENT VARIABLES section. It is now deduplicated by variable name.This is a minimal targeted fix for the affected commands. The underlying issue —
envVars()(help rendering) andOption.env()(actual wiring) being independent, so a mismatch between them is not detected anywhere — remains. If you are interested, I would be happy to follow up with a separate PR that adds a consistency test walking the command tree and asserting that every command declaringBACKLOG_PROJECTinenvVars()actually wires it to its--projectoption.Test plan
BACKLOG_PROJECTwhen--projectis omitted, and aBeeCommandtest asserting each env var is listed only once in help output.pnpm test(724 tests),pnpm typecheck,pnpm lint, andpnpm format --checkall pass.BACKLOG_PROJECTset and--projectomitted:document createsucceeded end-to-end: the project was resolved from the environment and the document was created (previously it aborted immediately in non-interactive mode).wiki createresolved the project from the environment and reached the API call (creation itself returned 403 because the wiki feature is disabled on the test space, which is unrelated to this change).document view <id> --web --no-browsernow prints the document URL containing the project key from the environment.--helpshows(env: BACKLOG_PROJECT)on the option, and the ENVIRONMENT VARIABLES section listsBACKLOG_PROJECTexactly once.