Uh oh!
There was an error while loading. Please reload this page.
feat: model /template/update fields as nullable so channels can be patched - #63
Merged
Conversation
…tched
`POST /template/update` is a partial update: a field absent from the request is
left alone, and only an explicit empty string clears a channel. The generated
request struct could not express that — the 14 channel-content fields,
`description` and `team_id` were value types with `omitempty`, so an empty
string meant the same thing as "unset" and clearing a channel through the SDK
was impossible.
Mark those properties nullable in the vendored spec, matching how
`feishu_app_card_v2_table_enabled` already models "omit keeps the current
setting", and regenerate. They become pointers, so nil omits the field and
`flashduty.String("")` clears the channel. `team_id` likewise: `Int64(0)` now
moves a template to account scope instead of being dropped by the encoder.
The vendored spec is edited in place rather than resynced wholesale so the diff
stays scoped to this schema; the nightly sync job reconciles the rest.
Two guards in flashduty_test.go, on the existing nullable-field tables: an
explicitly cleared channel must reach the wire, and an update that touches one
channel must not carry the others.Mirrors the upstream wording change so the vendored copy stays byte-identical to the source spec in that region and the nightly sync has nothing to report. The generator does not read x-mint.content, so the generated layer is unchanged -- 'make generate' reproduces the committed output exactly.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
POST /template/updateis a partial update: a field absent from the request is left alone, and only an explicit empty string clears a channel. The generated request struct could not express that.TemplateUpdateRequest's 14 channel-content fields,descriptionandteam_idwere value types withomitempty, so""encoded identically to "unset" — clearing a channel through the SDK was impossible, andTeamID: 0could never move a template to account scope.This marks those properties nullable in the vendored spec and regenerates. They become pointers:
Why the spec is edited in place
make sync-specpulls the whole upstream document, and the vendored copy is a few endpoints behind, so a wholesale resync would bury this schema in unrelated churn. The edit here is byte-identical to the corresponding region of the upstream spec (verified field by field), and the nightly sync job reconciles the rest on its own schedule.Ordering
Merge flashcatcloud/flashduty-docs#303 first. It carries the same change to the source-of-truth spec; landing this one first means the next nightly sync opens a PR that undoes it.
The pointer fields are correct against the server both before and after the corresponding server-side change ships — a nil field is omitted exactly as
omitemptyomitted a zero value today — so this can be released ahead of it.Checks
make generatereproduces the committed output (39 services, 336 operations, 707 schemas); the only non-spec diff ismodels_gen.go+ the doc comment onWriteUpdate.go build ./...,go build -tags e2e ./...,go vet ./...,go test ./...— all green.golangci-lint run(v2.11.4, the pinned version) — 0 issues.omitemptyreddens the "carries only the channel it changes" case.