Skip to content

fix(server): keep exception text out of responses, log it instead - #1

Closed
modusensus wants to merge 1 commit into
mainfrom
fix/example-server-error-text
Closed

modusensus wants to merge 1 commit into
mainfrom
fix/example-server-error-text

Conversation

@modusensus

Copy link
Copy Markdown
Owner

Draft: runs the security workflow (CodeQL, security-extended) against the error-text fix through a pull_request event before the change goes upstream as a PR. Closed once the scan has been read.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread laya/serve.py Fixed
examples/server.py answered an unexpected failure with
`f"{type(exc).__name__}: {exc}"` on all three surfaces: the /predict 500 detail,
the per-item `error` of /predict/batch, and the exception branch of the /gui
error page. Exception text names paths, libraries and memory sizes -- it
describes the deployment, not the request -- and code scanning reports it as
stack-trace exposure (py/stack-trace-exposure).

laya.serve already answers this way: a fixed "inference failed" to the caller,
the traceback to the log, asserted by
test_inference_failure_is_logged_and_not_leaked in tests/test_serve.py. The
demo now follows the same policy through a logger of its own, which also makes
the GUI's "the server log has the full trace" hint true.

laya/serve.py: the failure log interpolated the request's `model` straight into
the message (py/log-injection). `_resolve_model` has already reduced that value
to a shipped checkpoint name or None; replacing the line breaks keeps the log
line on one entry even if that stops holding, and keeps the checkpoint name
readable, which is the point of logging it at all.

tests/test_example_server_errors.py drives all three surfaces with a raising
router (no weights needed) and asserts the marker text reaches the log and
never a response, that a 4xx still carries its reason, and is wired into
ci.yml alongside the limits regression.

The 4xx paths are untouched: those messages name what the caller has to fix.
@modusensus
modusensus force-pushed the fix/example-server-error-text branch from 42430c4 to 8fd1b43 Compare September 27, 2026 18:07
@modusensus

Copy link
Copy Markdown
Owner Author

Scan read: 0 results for the branch (4 on main). The change is up as NandhaKishorM#625; this draft was only to run the security workflow through a pull_request event.

@modusensus modusensus closed this Sep 27, 2026
@modusensus
modusensus deleted the fix/example-server-error-text branch September 27, 2026 22:17
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.

2 participants