Skip to content

fix(api): /api/settings/set reports its real result - #615

Open
AnselmJo wants to merge 2 commits into
toniebox-reverse-engineering:developfrom
AnselmJo:fix/settings-set-response
Open

AnselmJo wants to merge 2 commits into
toniebox-reverse-engineering:developfrom
AnselmJo:fix/settings-set-response

Conversation

@AnselmJo

Copy link
Copy Markdown

POST /api/settings/set replies OK or ERROR, but clients could not see either:

  1. Empty body. The header announced Content-Length: 0, so the OK/ERROR text was never delivered. Clients only got an empty 200 and could not tell whether a setting was saved.
  2. Unknown setting reported as success. settings_set_by_string_id() returns bool, but for an unknown name it returned ERROR_NOT_FOUND. That value is non-zero, so it read as true and the API answered OK although nothing was set.

Fix: two one-line changes: send the real body length, and return false for an unknown setting.

Test: new tests/py/test_settings_set.py (make test_py TESTS=settings_set):

  • valid setting → 200 OK
  • unknown setting → 200 ERROR

Both tests pass with the fix and fail without it. Run natively on arm64 (Raspberry Pi 4, Ubuntu 24.04 container). I used NO_SANITIZERS=2 because ASan aborts there, see #311.

I found this while building a small web app on top of the API: it reads the value back after every set, because the reply could not be trusted.

🤖 Generated with Claude Code

AnselmJo and others added 2 commits November 19, 2026 16:14
The body ("OK"/"ERROR") was announced with Content-Length 0, so clients always
received an empty response and could not tell success from failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
settings_set_by_string_id() returns bool but returned ERROR_NOT_FOUND for an
unknown name, which is non-zero and therefore true. /api/settings/set then
answered OK although nothing was set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant