Skip to content

Fix 3 post-QA issues on api command#330

Merged
jeremy merged 5 commits into
mainfrom
fix/api-post-qa
Mar 16, 2026
Merged

Fix 3 post-QA issues on api command#330
jeremy merged 5 commits into
mainfrom
fix/api-post-qa

Conversation

@jeremy

@jeremy jeremy commented Mar 16, 2026

Copy link
Copy Markdown
Member

Summary

Fixes 3 issues found during QA of the api command on Windows (v0.4.1):

  • Leading slash breaks on Windows: parsePath now strips a leading slash instead of ensuring one. The SDK's accountPath and buildURL both prepend a slash, so keeping it in parsePath double-slashes — and on Windows, MSYS/Git Bash converts /path to C:\...\path before Go sees it. All 5 command examples updated to use bare paths (projects.json not /projects.json).

  • "ID required" instead of "path required": basecamp api get (no args) hit the global transformArgError which rewrites Cobra's generic missing-arg message to "ID required". Custom apiPathArgs validator emits "path required" directly.

  • --todolist leaks into agent help: emitAgentHelp dumped all inherited flags unfiltered. Extracted curatedInheritedFlags from filterInheritedFlags so both text and agent help share the same filtering: salientRootFlags allowlist, root pointer-identity check, and --project suppression for <id|url> commands.

Card: https://3.basecamp.com/2914079/buckets/46292715/card_tables/cards/9660578055

Test plan

  • bin/ci passes (lint, unit tests, e2e, surface snapshot, skill drift)
  • bin/basecamp api get --help — examples show projects.json not /projects.json
  • bin/basecamp api get — error says "path required"
  • bin/basecamp api --agent --help | jq .inherited_flags — no todolist
  • bin/basecamp subscriptions show --agent --help | jq .inherited_flags — no project
  • Windows: basecamp api get projects.json works without MSYS path mangling

jeremy added 3 commits March 16, 2026 00:53
MSYS/Git Bash on Windows converts /projects.json to C:\msys64\projects.json
before Go sees it. The SDK's accountPath and buildURL both prepend a slash,
so parsePath doesn't need one — strip it instead of ensuring it.

Update all api command examples to use bare paths (projects.json instead
of /projects.json) so they work directly on Windows.
The global transformArgError rewrites Cobra's generic missing-arg message
to "ID required". The api command's argument is <path>, not <id>, so use
a custom validator that emits "path required" directly.
emitAgentHelp was dumping all inherited flags unfiltered, leaking --todolist,
--verbose, etc. into --agent --help output. Extract curatedInheritedFlags
from filterInheritedFlags so both text and agent help share the same logic:
salientRootFlags allowlist, root pointer-identity check, and --project
suppression for <id|url> commands.
@jeremy jeremy requested a review from a team as a code owner March 16, 2026 07:56
Copilot AI review requested due to automatic review settings March 16, 2026 07:56
@github-actions github-actions Bot added commands CLI command implementations tests Tests (unit and e2e) breaking Breaking change labels Mar 16, 2026
@github-actions

github-actions Bot commented Mar 16, 2026

Copy link
Copy Markdown

⚠️ Potential breaking changes detected:

  • Change in the Example field for the 'api' command and its subcommands (get, post, put, delete) from having paths start with '/' to omitting the leading slash, which may break existing scripts that use the CLI with expected input format.
  • Modification of argument validation by replacing 'Args: cobra.ExactArgs(1)' with the new custom 'apiPathArgs' validation function, which changes error messages when arguments do not match expected patterns. Scripts depending on specific error outputs could break.

Review carefully before merging. Consider a major version bump.

@github-actions github-actions Bot added the bug Something isn't working label Mar 16, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/commands/api.go">

<violation number="1" location="internal/commands/api.go:205">
P2: The URL branch still returns a path with a leading slash (e.g. `/projects.json`), contradicting the new comment and the fix applied to the relative-path branch. If the SDK prepends its own slash, full-URL inputs will still double-slash.</violation>

<violation number="2" location="internal/commands/api.go:215">
P2: `apiBreadcrumbs` patterns all expect a leading `/` (e.g. `HasSuffix(path, "/projects.json")`, regex `/buckets/(\d+)`). Since `parsePath` no longer prepends one for relative paths, breadcrumbs will never match for bare-path inputs like `projects.json` or `buckets/123/todos/456.json`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread internal/commands/api.go
Comment thread internal/commands/api.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses QA-found issues in the basecamp api command and agent help output, with a focus on Windows path handling and consistent help flag curation.

Changes:

  • Updates api command examples and path parsing/arg validation to improve Windows compatibility and error messaging.
  • Introduces shared inherited-flag curation for both text help and --agent --help JSON output.
  • Adds unit tests for parsePath, apiPathArgs, and agent-help inherited-flag filtering behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/commands/api.go Updates examples, switches to custom arg validator, and changes parsePath behavior.
internal/commands/api_test.go Adds unit tests for parsePath and apiPathArgs.
internal/cli/root.go Uses curated inherited flags when emitting agent JSON help.
internal/cli/help.go Extracts shared curatedInheritedFlags used by both text and agent help.
internal/cli/help_test.go Adds tests asserting agent help inherited-flag filtering/suppression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/commands/api_test.go
Comment thread internal/cli/help_test.go
Comment thread internal/commands/api.go

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a0e936faf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cli/root.go
Comment thread internal/commands/api.go
parsePath now returns bare paths (no leading slash) for relative inputs,
but apiBreadcrumbs patterns expected a leading slash. Normalize the path
inside apiBreadcrumbs for pattern matching. Also update breadcrumb Cmd
strings to use bare paths matching the new convention.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

rootFlag := root.PersistentFlags().Lookup(f.Name)
if rootFlag == nil || rootFlag != f {
return // parent-scoped — already promoted to FLAGS

P2 Badge Preserve parent inherited flags in agent help output

This root-only filter drops every parent-scoped persistent flag from curatedInheritedFlags, and emitAgentHelp now uses this filtered set directly, so --agent --help can omit valid options entirely because agent help has no equivalent of text-help’s parent-flag promotion into flags. That breaks machine discovery for leaf commands that rely on parent flags (for example, messages list can use parent --message-board from internal/commands/messages.go:37), which now appears in neither flags nor inherited_flags. Fresh evidence: this commit changed emitAgentHelp to call curatedInheritedFlags(cmd) at internal/cli/root.go:731, so the drop now affects agent JSON output directly.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

emitAgentHelp now calls parentScopedFlags to promote non-root inherited
flags (e.g. --room on chat subcommands) into the flags section, matching
the text help promotion path. Without this, leaf commands lost valid
options entirely in --agent --help JSON output.

Also assert cmd.Execute() return value in agent help tests.
Copilot AI review requested due to automatic review settings March 16, 2026 08:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes QA-reported Windows and help-output issues for the basecamp api command by normalizing path handling, improving missing-arg validation, and aligning agent JSON help flag curation with text help.

Changes:

  • Updated api command examples and parsePath behavior to avoid leading-slash MSYS/Git Bash path mangling on Windows.
  • Added a custom positional-arg validator (apiPathArgs) so missing args report “path required” (instead of being rewritten to “ID required”).
  • Refactored inherited-flag filtering into curatedInheritedFlags and applied it to agent JSON help; also promotes parent-scoped flags into agent help flags to match text help behavior, with tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/commands/api.go Normalizes API path handling, updates examples, adds apiPathArgs, and fixes breadcrumbs matching for bare paths.
internal/commands/api_test.go Adds unit tests for parsePath and apiPathArgs behavior.
internal/cli/help.go Extracts inherited-flag curation into curatedInheritedFlags for shared use between text and agent help.
internal/cli/root.go Updates agent JSON help to promote parent-scoped flags and use curated inherited flags.
internal/cli/help_test.go Adds tests ensuring agent help filters inherited flags and promotes parent-scoped flags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeremy jeremy merged commit 7465cad into main Mar 16, 2026
30 checks passed
@jeremy jeremy deleted the fix/api-post-qa branch March 16, 2026 17:29
jeremy added a commit to brianevanmiller/basecamp-cli that referenced this pull request Mar 18, 2026
…evanmiller/feature-gap-analysis

* origin/main:
  Show full content in detail views instead of truncating at 40 chars (basecamp#338)
  Switch CODEOWNERS from sip to cli team (basecamp#346)
  Fix dock ordering and add --all flag to `projects show` (basecamp#333)
  Add file upload command to SKILL.md (basecamp#343)
  Replace "pending" with "incomplete" in todos output; omit from default view (basecamp#327)
  Add `--in` as global alias for `--project` (basecamp#334)
  Fix 3 post-QA issues on api command (basecamp#330)
  deps: bump the go-dependencies group with 2 updates (basecamp#331)
  Improve tool instance disambiguation format (basecamp#329)
  Fix emoji/CJK alignment in search results (basecamp#328)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking change bug Something isn't working commands CLI command implementations tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants