Repository navigation
fix(API): make translation update content/branch/plural_suffix nullable #STRINGS-3652 - #1325
Mikko Karkee (Varpuspaavi) wants to merge 3 commits into
Conversation
…le #STRINGS-3652
Plain string fields generate Go structs with omitempty, so the CLI dropped
{"content":""} before sending and clearing a translation silently no-op'd.
Marking them nullable generates *NullableString, which preserves an empty
string on the wire.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
API changelog (oasdiff)Doc-only edits (descriptions, examples) do not appear here. |
…n #STRINGS-3652
The CLI and Go client still drop {"content":null}; only document the
empty string as the way to clear content.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Same omitempty issue as translation update: an empty description was dropped client-side, so clearing a key description silently no-op'd. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Efe Bikmaz (bikmazefe)
left a comment
There was a problem hiding this comment.
Two review notes on the nullable change.
| description: Translation content | ||
| description: Translation content. Send an empty string to clear the translation's content; omit the field to leave it unchanged. | ||
| type: string | ||
| nullable: true |
There was a problem hiding this comment.
nullable: true advertises null as a valid value, but the description tells callers to send an empty string, and the PR notes {"content":null} is still dropped by the CLI. The spec, the prose and the CLI behaviour disagree: generated clients will accept null, while the CLI silently ignores it. Consider either documenting the null semantics (and the CLI limitation) or rewording the description so it doesn't imply null is unsupported.
| branch: | ||
| description: specify the branch to use | ||
| type: string | ||
| nullable: true |
There was a problem hiding this comment.
This changes the generated Go model type for branch, content and plural_suffix (and description in keys update) from string to *NullableString. That is source-breaking for typed phrase-go consumers, e.g. body.Content = "x" stops compiling, and other typed clients (Java, Swift, TypeScript) change field types too. oasdiff only reports it as info. Could the PR description call this out and say what release/version bump it needs?
Problem
STRINGS-3652:
phrase translations update --data '{"content":""}'returns success but leaves the translation unchanged. The same payload sent directly to the API clears it.content,branchandplural_suffixontranslation/updatewere plaintype: string, so the generated Go model usesstringwithjson:",omitempty". The CLI unmarshals--datainto that struct and re-marshals it, andomitemptydrops"", so the key never reaches the API.Change
paths/translations/update.yaml: markbranch,content,plural_suffixasnullable: true; document that an empty string clearscontentand omitting it leaves it unchanged (nulldeliberately not documented, see limitation below).paths/keys/update.yaml: markdescriptionasnullable: true(sameomitemptybug; empty string now clears it).doc/compiled.json: regenerated (make bundle).Generated Go model now uses
*NullableString(same pattern asrepo_syncname).clients/is gitignored and regenerated on release.Verification
Ran
make goand a throwaway marshal round-trip on the generated model:{"content":""}{"content":""}{"content":"x"}{"content":"x"}{}{}{"content":null}{}swagger-cli validate main.yamlpasses. Other language generators were not run.Known limitation (out of scope)
{"content":null}through the CLI is still dropped:encoding/jsonsets a*NullableStringtonilon JSONnullwithout callingUnmarshalJSON. Fixing it needs a Go model template change affecting all nullable fields, so it is deliberately not done here. Direct API calls withnullare unaffected.Follow-up
Once released,
phrase-clineeds aphrase-godependency bump to pick this up.🤖 Generated with Claude Code