Skip to content

fix: preserve explicit notification preference false - #57

Merged
ysyneu merged 2 commits into
mainfrom
fix/notify-follow-preference
Aug 12, 2026
Merged

fix: preserve explicit notification preference false#57
ysyneu merged 2 commits into
mainfrom
fix/notify-follow-preference

Conversation

@ysyneu

@ysyneu ysyneu commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What

assigned_to.notify.follow_preference / notify.follow_preference is a tri-state field:

  • omitted — use each responder's personal notification preference;
  • true — explicitly use the personal preference;
  • false — use the personal_channels listed in the request.

The OpenAPI schema modelled it as an optional non-nullable boolean, so the generator emitted
FollowPreference bool with omitempty. Go's encoder drops false, so the SDK could never send
the one value that activates personal_channels — a request carrying personal_channels was
accepted but delivered over the responder's personal preference instead.

Change

Model the field as "type": ["boolean", "null"] in the OpenAPI source (already merged upstream in
flashduty-docs) and re-sync + regenerate. The generator's existing nullable-request-scalar rule
turns it into a pointer:

FollowPreference *bool `json:"follow_preference,omitempty"`

Callers send an explicit false with flashduty.Bool(false); a nil pointer stays off the wire.
The same contract backs incident creation, responder addition and incident assignment, so all three
request schemas are corrected and AssignedTo now exposes notify.

.gitignore additionally covers local-only scratch directories so they cannot be committed by accident.

Compatibility

FollowPreference changes from bool to *bool on the three request-side notify structs. Keyed
literals that set the field must switch to flashduty.Bool(true) / flashduty.Bool(false).
Response-side structs (ScheduleNotifyBy, EscalateTargetBy, FeedDetailIncidentAssignNotify) and
the escalation-rule / schedule request structs are unchanged — their backend counterparts are plain
booleans where omitted is equivalent to false.

Validation

  • make check — gofmt/gci clean, golangci-lint 0 issues, go test -race ./... green, build OK.
  • New generator test: an optional nullable request boolean emits *bool with omitempty.
  • New wire tests over /incident/create, /incident/responder/add and /incident/assign:
    Bool(false) serialises as "follow_preference":false; nil omits the key entirely.

Replaces #56 (same code, rebased onto a clean history).

@ysyneu
ysyneu merged commit 078cb15 into main Aug 12, 2026
4 checks passed
@ysyneu
ysyneu deleted the fix/notify-follow-preference branch August 12, 2026 08:47
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