Skip to content

fix: accept an attachment scalar as either a string or a number - #7

Merged
pikonha merged 1 commit into
mainfrom
fix/attachment-scalars
Aug 18, 2026
Merged

fix: accept an attachment scalar as either a string or a number#7
pikonha merged 1 commit into
mainfrom
fix/attachment-scalars

Conversation

@pikonha

@pikonha pikonha commented Aug 18, 2026

Copy link
Copy Markdown
Member

#6 retyped Attachment.Date from int64 to string because ClickUp sends it as "1749381600000". Today the mirror image landed on the next field along:

json: cannot unmarshal number into Go struct field Attachment.attachments.version of type string

ClickUp is not consistent about which JSON scalar it uses here, and it can differ between the attachment endpoint and the copy embedded in a task response. Either Go scalar is therefore wrong: whichever is declared, some real response fails to unmarshal — and since the field sits inside every task payload, the blast radius is task get and task update for any task carrying an attachment. The write applies server-side and still returns UNMARSHAL_ERROR, so a caller cannot tell it from a genuine failure.

FlexString accepts both shapes and normalises to the string form, keeping JSON output stable for consumers. Anything that is not a scalar still fails loudly rather than landing as "". Both Version and Date use it; the regression test pins both shapes plus the rejection.

go vet clean, internal/api green. cmd.TestParseSince fails on main too (timezone-dependent, unrelated).

🤖 Generated with Claude Code

#6 retyped `Attachment.Date` from int64 to string because ClickUp sends it as
"1749381600000". Today the mirror image landed on the next field along:

    json: cannot unmarshal number into Go struct field
    Attachment.attachments.version of type string

ClickUp is simply not consistent about which JSON scalar it uses here, and it can
differ between the attachment endpoint and the copy embedded in a task response.
Either Go scalar is therefore the wrong choice: whichever one is declared, some
real response fails to unmarshal, and because the field sits inside every task
payload the blast radius is `task get` AND `task update` for any task carrying an
attachment -- the write applies server-side and still reports UNMARSHAL_ERROR, so
a caller cannot tell it from a genuine failure. A queue-driven agent hit exactly
that twice and both times spent the run on the CLI instead of the work.

FlexString accepts both shapes and normalises to the string form, keeping the
JSON output stable for consumers. It rejects anything that is not a scalar, so a
real shape change still fails loudly rather than landing as "". Both fields use
it; the regression test pins both shapes and the rejection.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@pikonha
pikonha merged commit bbfcdff into main Aug 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant