Fix set-alias endpoint: return HTTP 200 with normalized error key on failure#1600
Merged
jokob-sk merged 2 commits intonext_releasefrom Apr 8, 2026
Merged
Fix set-alias endpoint: return HTTP 200 with normalized error key on failure#1600jokob-sk merged 2 commits intonext_releasefrom
error key on failure#1600jokob-sk merged 2 commits intonext_releasefrom
Conversation
…failure Agent-Logs-Url: https://github.com/netalertx/NetAlertX/sessions/05ab18a3-4ac2-492d-bb80-67a1cc089bd9 Co-authored-by: jokob-sk <96159884+jokob-sk@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix error response for set alias endpoint
Fix set-alias endpoint: return HTTP 200 with normalized Apr 8, 2026
error key on failure
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 free
to 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.
📌 Description
POST /device/<mac>/set-aliaswas returning HTTP 404 whenupdateDeviceColumnreported failure. The testtest_set_device_alias_not_foundcorrectly expects HTTP 200 with the error in the JSON body — consistent with every other endpoint in this API that uses the{"success": false, "error": "..."}envelope pattern rather than HTTP status codes to communicate domain errors.Change in
api_device_set_alias:success+errorfieldserrorfirst, falls back tomessage, then a contextual default🔍 Related Issues
📋 Type of Change
📷 Screenshots or Logs (if applicable)
Before:
FAILED test/api_endpoints/test_mcp_tools_endpoints.py::test_set_device_alias_not_found—AssertionError: assert 404 == 200After: Test passes; CodeQL: 0 alerts.
🧪 Testing Steps
test_set_device_alias_not_found— mocksupdateDeviceColumnreturning{"success": False, "error": "Device not found"}, asserts status 200 anddata["error"]contains "Device not found"test_set_device_alias— success path unchanged, still passes✅ Checklist
🙋 Additional Notes
The
error/messagefallback is intentional:updateDeviceColumnmay return either key depending on the failure path; this handler normalises both intoerrorfor a consistent API surface.Original prompt
This pull request was created from Copilot chat.