Escape msg before embedding in JSON payload in mps_parser_throw
Open
@aliceb-nv is already working on this.
Since Jun 15, 2026.
awaiting response
- Dominant language
- Cuda
- Stars
- 1k
- Forks
- 233
- Avg merge
- 4d 4h
- Merged PRs (30d)
- 95
Description
Summary
mps_parser_throw() (in cpp/src/io/utilities/error.hpp) concatenates msg verbatim into a JSON string. A token, file path, or system error message containing ", \, or a newline will produce malformed JSON and break any downstream consumer expecting the MPS_PARSER_ERROR_TYPE / msg structure.
Suggested fix
Add a small json_escape(const std::string&) helper that replaces \, ", \n, \r, and \t with their JSON-escaped forms, and apply it when constructing the thrown std::logic_error message in mps_parser_throw.
References
- Raised during review of PR #1429 (experimental fast MPS parser): https://github.com/NVIDIA/cuopt/pull/1429#discussion_r3404570407
- Deferred from that PR by @aliceb-nv to be addressed in a follow-up.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.