Skip to content

fix: omit empty value on SetOrganizationFeature requests - #151

Open
HusseinAdeiza wants to merge 1 commit into
tkhq:mainfrom
HusseinAdeiza:fix/set-organization-feature-empty-value
Open

HusseinAdeiza wants to merge 1 commit into
tkhq:mainfrom
HusseinAdeiza:fix/set-organization-feature-empty-value

Conversation

@HusseinAdeiza

Copy link
Copy Markdown

SetOrganizationFeatureRequest.Value is generated without omitempty, so every request sends "value": "", and features that take no value reject it with a 400.

The spec is the source: v1SetOrganizationFeatureIntent lists value as required while its own description says "Optional value for the feature". It is the only definition in the spec with that mismatch.

I fixed it in types_extensions.go rather than the vendored swagger, since codegen/inputs/public_api.swagger.json is synced from the API repo (chore: sync from mono) and an edit there would be reverted on the next sync. Value stays a plain string so existing callers are unaffected.

func TestActivityEnvelope_SetOrganizationFeatureOmitsEmptyValue(t *testing.T) {
	// FAILS on master: map[... {"name":"FEATURE_NAME_OTP_EMAIL_AUTH", "value":""}] should not contain "value"
}

The proper long-term fix is dropping value from required in the API spec, which makes the generator emit Value *string on its own.

Fixes #150

The API spec lists value as required while its own description calls it
optional, so the generated struct tags it `json:"value"` and every
request sends `"value": ""`. Features that take no value reject that
with a 400:

    invalid value for feature (FEATURE_NAME_OTP_EMAIL_AUTH): Some("")

MarshalJSON drops the field when Value is empty, leaving the public API
unchanged so existing callers keep passing a plain string. Fixes tkhq#150.

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.

SetOrganizationFeature always sends an empty value, which the API rejects

1 participant