Skip to content

fix: include ANTLR diagnostic in loads() ValidationError - #452

Open
tonycoder-hub wants to merge 1 commit into
qBraid:mainfrom
tonycoder-hub:fix/loads-parse-error-antlr-message
Open

tonycoder-hub wants to merge 1 commit into
qBraid:mainfrom
tonycoder-hub:fix/loads-parse-error-antlr-message

Conversation

@tonycoder-hub

Copy link
Copy Markdown
Contributor

Summary of changes

openqasm3.parse often raises QASM3ParsingError with an empty message while printing the ANTLR diagnostic to stderr. pyqasm.loads() then produced ValidationError: Failed to parse OpenQASM string: with no reason for callers.

Capture stderr during parse and prefer that text when the exception message is empty, so the ValidationError includes the diagnostic (e.g. line 3:10 no viable alternative…).

Fixes #436

@argus-eye

argus-eye Bot commented Oct 12, 2026

Copy link
Copy Markdown

Argus review

Auto-review is off for this repo. Tick the box below to run a review on this PR.

  • Trigger Argus review

Estimated cost

  • Files changed: 2
  • Diff lines (±): 24
  • Historical avg: ~350.7k tokens · ~$1.38 · across last 13 review(s)

Tip: you can also comment @argus-eye review at any time.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: qBraid/pyqasm/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 369ea70e-bd6b-40dc-8bc1-632e9be016e3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@tonycoder-hub
tonycoder-hub force-pushed the fix/loads-parse-error-antlr-message branch from cfc7dd9 to e2719b4 Compare October 12, 2026 11:14
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

openqasm3 often raises QASM3ParsingError with an empty message while
writing the real ANTLR diagnostic to stderr. Capture stderr during
parse so ValidationError carries a useful reason for callers.

Signed-off-by: Tony Coder <407243179@qq.com>
@tonycoder-hub
tonycoder-hub force-pushed the fix/loads-parse-error-antlr-message branch from 05949db to 69414d3 Compare October 15, 2026 09:48

This branch has not been deployed

No deployments
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.

Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost

2 participants