Skip to content

fix(api): a mixed-case grace_period_days key merges instead of replacing #1658

Open

Description

@cristim

PUT /api/config checks whether the body carries grace_period_days with an exact-case map lookup (internal/api/handler_config.go:75, present["grace_period_days"]). json.Unmarshal matches keys case-insensitively.

Failure scenario: a stored config has {"aws": 7, "azure": 3}, and a client sends {"Grace_Period_Days": {"aws": 5}}. The presence check misses the key, so the stored map is not reset (line 111). json.Unmarshal then merges into it, and the result is {"aws": 5, "azure": 3} instead of {"aws": 5}. The key the client dropped stays.

Impact is low: the frontend sends the exact key. Fix: detect the key with a case-insensitive check, like the one riExchangeModeSent uses (or the bodyHasKey helper from #1656 once it merges), and add a test with a mixed-case key.

Found by the cold review of #1656.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions