Skip to content

fix(API): make translation update content/branch/plural_suffix nullable #STRINGS-3652 - #1325

Open
Mikko Karkee (Varpuspaavi) wants to merge 3 commits into
mainfrom
STRINGS-3652-nullable-translation-update
Open

Mikko Karkee (Varpuspaavi) wants to merge 3 commits into
mainfrom
STRINGS-3652-nullable-translation-update

Conversation

@Varpuspaavi

@Varpuspaavi Mikko Karkee (Varpuspaavi) commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

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, branch and plural_suffix on translation/update were plain type: string, so the generated Go model uses string with json:",omitempty". The CLI unmarshals --data into that struct and re-marshals it, and omitempty drops "", so the key never reaches the API.

Change

  • paths/translations/update.yaml: mark branch, content, plural_suffix as nullable: true; document that an empty string clears content and omitting it leaves it unchanged (null deliberately not documented, see limitation below).
  • paths/keys/update.yaml: mark description as nullable: true (same omitempty bug; empty string now clears it).
  • doc/compiled.json: regenerated (make bundle).

Generated Go model now uses *NullableString (same pattern as repo_sync name). clients/ is gitignored and regenerated on release.

Verification

Ran make go and a throwaway marshal round-trip on the generated model:

Input Output
{"content":""} {"content":""}
{"content":"x"} {"content":"x"}
{} {}
{"content":null} {}

swagger-cli validate main.yaml passes. Other language generators were not run.

Known limitation (out of scope)

{"content":null} through the CLI is still dropped: encoding/json sets a *NullableString to nil on JSON null without calling UnmarshalJSON. Fixing it needs a Go model template change affecting all nullable fields, so it is deliberately not done here. Direct API calls with null are unaffected.

Follow-up

Once released, phrase-cli needs a phrase-go dependency bump to pick this up.

🤖 Generated with Claude Code

…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]>
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

API changelog (oasdiff)

Doc-only edits (descriptions, examples) do not appear here.

4 changes: 0 error, 0 warning, 4 info
info	[request-property-became-nullable] at doc/compiled.json
	in API PATCH /projects/{project_id}/keys/{id}
		the request property `description` became nullable

info	[request-property-became-nullable] at doc/compiled.json
	in API PATCH /projects/{project_id}/translations/{id}
		the request property `branch` became nullable

info	[request-property-became-nullable] at doc/compiled.json
	in API PATCH /projects/{project_id}/translations/{id}
		the request property `content` became nullable

info	[request-property-became-nullable] at doc/compiled.json
	in API PATCH /projects/{project_id}/translations/{id}
		the request property `plural_suffix` became nullable

…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]>

@bikmazefe Efe Bikmaz (bikmazefe) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

This branch has not been deployed

No deployments
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.

2 participants