Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost
Maintainers usually reply within 1 day
@PranavHariharan19 is already working on this.
Since Oct 6, 2026.
- #452 by @tonycoder-hub — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 22/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- developer-experience
Research direction
The empty message comes from the ValidationError raised when pyqasm.loads() catches a parse failure; openqasm3/parser.py:107 re-raises QASM3ParsingError with no text, and the ANTLR diagnostic only reaches stderr. Read how the error listener is attached before changing anything. Linked PR #452 is already open against this, so check its status first. Done means str(exc) includes the line, column and ANTLR message.
Written by the indexing model from the issue text.
Description
Summary
When pyqasm.loads() fails to parse, the ValidationError message is "Failed to parse OpenQASM string: " with nothing after the colon. The ANTLR diagnostic that says what is wrong (line 3:10 no viable alternative at input 'rx(pi/2q') goes to stderr only, so a service that surfaces str(exc) to a user gives them an empty reason.
Repro (pyqasm 1.2.1, openqasm3 1.0.1)
import pyqasm
try:
pyqasm.loads("OPENQASM 3.0;\nqubit q;\nrx(pi / 2 q;\n")
except Exception as exc:
print(repr(str(exc)))
# prints: 'Failed to parse OpenQASM string: '
# stderr: line 3:10 no viable alternative at input 'rx(pi/2q'
openqasm3.parser.QASM3ParsingError is raised with no message (raise QASM3ParsingError() from exc in openqasm3/parser.py:107), so {err} formats as empty.
Suggestion
Capture the ANTLR error listener output (line, column, message) and put it in the ValidationError message, e.g. Failed to parse OpenQASM string: line 3:10 no viable alternative at input 'rx(pi/2q'. Line and column would also let callers point at the offending statement.
- Dominant language
- Python
- Stars
- 29
- Forks
- 33
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from qBraid/pyqasm
-
dumps() prints the original program when unroll() leaves at most one statementPossibly taken @ShiveshDragon claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
qBraid/pyqasm#493 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
enhancement error-handling program-validation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 43/100
Maintainers usually reply within 1 day
-
dependencies enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
auto-reported bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
backend bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
nolte/kamerplanter#3193 ·
Maintainers usually reply within 1 day
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePossibly taken @abdulwaarith0 claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MakazhanAlpamys/Soup#3690 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day