fix(web-server): return 400 for invalid env var names instead of 500 - #36807
Closed
kyssta-exe wants to merge 1 commit into
Closed
fix(web-server): return 400 for invalid env var names instead of 500#36807kyssta-exe wants to merge 1 commit into
kyssta-exe wants to merge 1 commit into
Conversation
The PUT /api/env endpoint calls save_env_value() which raises ValueError for invalid env var names (e.g. empty key, invalid characters). The catch-all 'except Exception' returned HTTP 500, making validation errors appear as internal server errors. Fix: catch ValueError before the generic handler and return HTTP 400 with the specific validation error message.
mxnstrexgl
approved these changes
Jun 1, 2026
mxnstrexgl
left a comment
There was a problem hiding this comment.
🤖 Automated PR Review
Security Scan
- ✓ No hardcoded secrets, injection sinks, unsafe deserialization, or dependency red flags found by this automated scan.
Code Quality
- ✓ No blocking code-quality issues found by this automated scan.
- ℹ️ No test file changes detected; verify existing coverage exercises this behavior.
Summary
Status: APPROVE — security findings: 0, quality suggestions: 0.
Automated review; raw diff content intentionally omitted.
Contributor
Author
|
👋 tiny fix — catches ValueError from save_env_value/remove_env_value and returns HTTP 400 instead of 500. Same pattern already applied to PUT /api/env in an earlier merge. Ready for review! |
Contributor
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.
The
PUT /api/envendpoint callssave_env_value()which raisesValueErrorfor invalid env var names (e.g. empty key, invalid characters). The catch-allexcept Exceptionreturned HTTP 500, making validation errors appear as internal server errors.Fix: catch
ValueErrorbefore the generic handler and return HTTP 400 with the specific validation error message.