Skip to content

Preserve untouched document fields in files update#441

Open
robzolkos wants to merge 4 commits intomainfrom
fix/files-update-preserve-document-fields
Open

Preserve untouched document fields in files update#441
robzolkos wants to merge 4 commits intomainfrom
fix/files-update-preserve-document-fields

Conversation

@robzolkos
Copy link
Copy Markdown
Collaborator

@robzolkos robzolkos commented Apr 20, 2026

Summary

Fixes a data-loss hazard in basecamp files update for documents. When callers updated only --title or only --content, the untouched field could be cleared because document updates are backed by a destructive PUT-style API contract. The CLI now fetches the current document first and preserves the existing title/content before applying the requested change, so partial document updates behave the way users and agents expect.

Ref: https://3.basecamp.com/2914079/buckets/46292715/card_tables/cards/9805158815

Also adds regression coverage for title-only and content-only document updates, and updates the Basecamp skill/docs to make the safer partial-update behavior explicit.


Summary by cubic

Prevents data loss in basecamp files update for documents by preserving untouched title/content when only one field changes. Adds safe clears with empty flags and tightens validation (including autodetect vaults) to prevent invalid updates.

  • Bug Fixes
    • Document updates use buildDocumentUpdateRequest to fetch and merge existing fields when only one flag is set, converting Markdown and resolving local images only when content changes.
    • Honors empty flags to clear fields by omitting them from the PUT body; detects whether --title/--content were set so no flags show a no-op message.
    • Validates updates by --type and in autodetect mode: rejects --content for vault/folder (including content-only updates when the ID resolves to a vault), requires a change for each type, and shows usage hints on invalid types; adds tests and updates help text and skills/basecamp/SKILL.md.

Written for commit 657e20d. Summary will update on new commits.

Copilot AI review requested due to automatic review settings April 20, 2026 14:36
@github-actions github-actions Bot added commands CLI command implementations tests Tests (unit and e2e) skills Agent skills bug Something isn't working labels Apr 20, 2026
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 prevents data loss when running basecamp files update on documents by preserving the untouched title/content field during partial updates (because the underlying API behaves like a destructive PUT).

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Update document handling in files update to fetch the current document and merge fields for title-only/content-only updates.
  • Add regression tests covering title-only and content-only document updates.
  • Document the safer partial-update semantics in the Basecamp skill docs.

Reviewed changes

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

File Description
internal/commands/files.go Builds document update requests by merging existing fields to avoid clearing omitted title/content on PUT-style updates.
internal/commands/files_test.go Adds tests that assert the request body preserves the untouched document field during partial updates.
skills/basecamp/SKILL.md Updates examples and explicitly documents the CLI’s partial-update semantics for documents.

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

Comment thread internal/commands/files.go Outdated
Comment thread internal/commands/files.go Outdated
Comment thread internal/commands/files.go Outdated
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 3 files

Copilot AI review requested due to automatic review settings April 20, 2026 15:12
@robzolkos robzolkos force-pushed the fix/files-update-preserve-document-fields branch from 9781615 to 3abd94f Compare April 20, 2026 15:12
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 3 out of 3 changed files in this pull request and generated 2 comments.


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

Comment thread internal/commands/files.go Outdated
Comment thread skills/basecamp/SKILL.md Outdated
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.

1 issue found across 3 files (changes from recent commits).

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/files.go">

<violation number="1" location="internal/commands/files.go:1223">
P2: Content-only updates without `--type` can auto-detect to vault and incorrectly send a vault title update with an empty/unset title instead of returning a usage error.</violation>
</file>

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

Comment thread internal/commands/files.go
Copilot AI review requested due to automatic review settings April 20, 2026 15:38
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 3 out of 3 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.

@robzolkos robzolkos requested a review from jeremy April 20, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working commands CLI command implementations skills Agent skills tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants