server : add request path to 404 error message#24409
Open
Jinpop wants to merge 1 commit into
Open
Conversation
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.
Overview
This PR updates the 404 response to include the requested path.
Previously, missing routes returned only "File Not Found", which made it unclear which path caused the error. This led to confusion in cases like #24224, where the user thought the server was running on the wrong port.
Fixes #24279
Additional information
Before:
{"error":{"message":"File Not Found","type":"not_found_error","code":404}}After:
{"error":{"message":"File Not Found: /app","type":"not_found_error","code":404}}Tests
Added test_404_error_includes_path, which verifies that a request to a missing route returns 404 and includes the requested path in the error message.
Local Verification
Verified locally on macOS Apple Silicon. The new test and the existing test_no_webui test both pass.
The path is also safe to include even when it contains invalid UTF-8, since the response is serialized through safe_json_to_str, which already uses error_handler_t::replace.
Requirements
The design decisions were made by me, including the response message format, keeping the existing "File Not Found" prefix for compatibility, and defining the test scenario.
AI was used to assist with issue and codebase exploration, build/reproduction/test execution, typing the code according to my design, and reviewing the changes. The commit message wording was also suggested by AI.
I personally reviewed and understood every changed line in this PR.