Preserve untouched document fields in files update#441
Preserve untouched document fields in files update#441
Conversation
There was a problem hiding this comment.
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 updateto 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.
9781615 to
3abd94f
Compare
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Summary
Fixes a data-loss hazard in
basecamp files updatefor documents. When callers updated only--titleor 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 updatefor 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.buildDocumentUpdateRequestto fetch and merge existing fields when only one flag is set, converting Markdown and resolving local images only when content changes.--title/--contentwere set so no flags show a no-op message.--typeand in autodetect mode: rejects--contentforvault/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 andskills/basecamp/SKILL.md.Written for commit 657e20d. Summary will update on new commits.