Skip to content

Fix chat post JSON output contract and upload error handling#365

Merged
jeremy merged 3 commits intomainfrom
fix-chat-post-json-contract
Mar 24, 2026
Merged

Fix chat post JSON output contract and upload error handling#365
jeremy merged 3 commits intomainfrom
fix-chat-post-json-contract

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Mar 24, 2026

Summary

  • The --attach addition (cbaf4c5) replaced the CampfireLine return with a synthetic {"message_id", "upload_ids"} map, breaking --json consumers expecting Line fields and mismatching the chat_line schema presenter
  • Restores *basecamp.CampfireLine return for text-only posts (preserves backward compatibility); uses composite map only when uploads are involved, without the chat_line entity hint
  • Routes upload errors through convertSDKError (was using raw fmt.Errorf, losing SDK error code/hint extraction)
  • Renames contentType variable shadow to mimeType in the upload loop

Test plan

  • make test — all pass
  • make lint — clean
  • Manual: basecamp chat post "hello" --in <project> --json should return full CampfireLine JSON
  • Manual: basecamp chat post "hello" --attach <file> --in <project> should return composite result

Summary by cubic

Restores the chat post JSON contract. Text-only posts return the full *basecamp.CampfireLine with display data; uploads return a compact map with message_id and/or upload_ids. Improves error handling and keeps SDK error codes, including file path context for failed uploads.

  • Bug Fixes
    • Return *basecamp.CampfireLine for text-only posts; set entity to chat_line and add WithDisplayData(chatLineDisplayData(line)).
    • For uploads, return a composite result without the chat_line entity; include message_id when present and upload_ids for attachments.
    • Route CreateLine and CreateUpload errors through convertSDKError; preserve the failing file path in structured SDK errors; rename shadowed contentType to mimeType.

Written for commit 49eb2fc. Summary will update on new commits.

Copilot AI review requested due to automatic review settings March 24, 2026 16:42
@github-actions github-actions bot added commands CLI command implementations bug Something isn't working labels Mar 24, 2026
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Copy Markdown

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

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: 0ab2135353

ℹ️ 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".

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR restores the basecamp chat post --json output contract by returning a full CampfireLine object for text-only posts, while returning a composite {message_id, upload_ids} result only when attachments are involved. It also improves attachment-upload error handling to preserve structured SDK error codes/hints, and removes a local variable shadow in the upload loop.

Changes:

  • Return *basecamp.CampfireLine for text-only chat posts (and only use the composite ID map when uploads are present).
  • Route CreateUpload errors through convertSDKError for consistent structured CLI errors.
  • Rename the inner contentType shadow to mimeType in the upload loop.

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

Copilot AI review requested due to automatic review settings March 24, 2026 17:02
@jeremy jeremy force-pushed the fix-chat-post-json-contract branch from e54979b to c9aa7bd Compare March 24, 2026 17:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


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

Copy link
Copy Markdown

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

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: c9aa7bd47e

ℹ️ 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".

@github-actions github-actions bot added the breaking Breaking change label Mar 24, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Potential breaking changes detected:

  • Change in JSON output contract: the response format for the 'runChatPost' function has been modified. Previously, the response always included 'message_id' (even if it defaulted to 0) and 'upload_ids'. Now, the response differentiates between cases where there are no uploads, returning just the 'line' object, and cases where uploads are involved, returning a composite result. This change could break existing scripts dependent on the specific structure of the JSON output.

Review carefully before merging. Consider a major version bump.

@jeremy jeremy enabled auto-merge (squash) March 24, 2026 19:06
jeremy added 3 commits March 24, 2026 12:18
The --attach addition (cbaf4c5) changed chat post to return a
synthetic map instead of the CampfireLine object, breaking --json
consumers and mismatching the chat_line schema presenter.

Restore CampfireLine return for text-only posts (the common case).
Use a composite map only when uploads are involved, without the
chat_line entity hint that doesn't fit the map shape.

Also: route upload errors through convertSDKError for proper error
code extraction, and rename contentType shadow to mimeType.
- Preserve filePath context in upload errors: wrap with fmt.Errorf
  before convertSDKError so users know which file failed
- Add WithDisplayData(chatLineDisplayData(line)) for text-only posts
  so styled/markdown output renders consistently with other chat commands
- Route CreateLine errors through convertSDKError for structured error
  codes/hints
convertSDKError unwraps to find *basecamp.Error and reconstructs
output.Error from its fields, discarding any fmt.Errorf wrapper
context. Prefix filePath into the converted error's Message so
users know which file failed in multi-attachment uploads.
Copilot AI review requested due to automatic review settings March 24, 2026 19:18
@jeremy jeremy force-pushed the fix-chat-post-json-contract branch from c55b77d to 49eb2fc Compare March 24, 2026 19:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

@jeremy jeremy merged commit 5c9299c into main Mar 24, 2026
30 checks passed
@jeremy jeremy deleted the fix-chat-post-json-contract branch March 24, 2026 19:21
jeremy added a commit that referenced this pull request Mar 25, 2026
Cherry-picked fixes from pending main PRs:
- Fix --assignee filter ignored with --list (#369)
- Fix chat post JSON output contract and upload error handling (#365)
- Fix schedule update silently dropping --attach without --description (#364)
- Fix blank-line-after-list suppressing paragraph break (#363)
- Fix campfire messages --limit being ignored (#367)
jeremy added a commit that referenced this pull request Mar 25, 2026
jeremy added a commit that referenced this pull request Mar 25, 2026
jeremy added a commit that referenced this pull request Mar 25, 2026
Also fixes: chat upload error now wraps converted SDK error instead of
raw error; schedule update --attach without --description now fetches
current description to append rather than replace.
jeremy added a commit that referenced this pull request Mar 25, 2026
Also fixes: chat upload error now wraps converted SDK error instead of
raw error; schedule update --attach without --description now fetches
current description to append rather than replace.
jeremy added a commit that referenced this pull request Mar 25, 2026
…accounts (#373)

* Bump basecamp-sdk to v0.7.1

Fixes Person.Id deserialization (normalizeJSON pre-unmarshal for
notification responses) and Account.Logo type (string → AccountLogo
object). Adapts two breaking changes: Cards().Move() and
Todos().Reposition() now take optional params.

Adds AVIF/HEIC to richtext MIME extension map for logo upload support.

* Merge upstream fixes (#363, #364, #365, #367, #369)

Also fixes: chat upload error now wraps converted SDK error instead of
raw error; schedule update --attach without --description now fetches
current description to append rather than replace.

* Add gauges command for project progress tracking

Subcommands: list (account-wide), needles/needle (project-scoped),
create/update/delete, enable/disable. Create validates --position
(0-100), --color, --notify (requires --subscriptions for custom mode).

* Add assignments command for viewing my assignments

Subcommands: list, completed, due (with scope filter). Shortcut
pattern — bare invocation shows priorities + non-priorities.

* Add notifications command, extend accounts, register all new commands

Notifications: list (paginated with dynamic next-page breadcrumb) and
read (resolves IDs to SGIDs from --page). Accounts: show, update, logo
upload (5MB + image type validation) and remove. Registers all new
commands in root.go, catalog, and test harness.

* Update docs and surface for v0.7.1 commands

API-COVERAGE.md: 42 sections, 155 endpoints, SDK v0.7.1.
SKILL.md: gauges, assignments, notifications, accounts sections.
.surface: 148 commands, 422 flags.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants