Skip to content

Show the stanc error when format_stan_file fails - #883

Merged
WardBrian merged 1 commit into
stan-dev:developfrom
soujasK:fix/format-stan-file-stanc-error
Nov 30, 2026
Merged

WardBrian merged 1 commit into
stan-dev:developfrom
soujasK:fix/format-stan-file-stanc-error

Conversation

@soujasK

@soujasK soujasK commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

format_stan_file runs stanc with check=True, but only caught ValueError and RuntimeError, so a stanc failure raised a raw subprocess.CalledProcessError without stanc's message. This catches it and raises RuntimeError with stanc's stderr, like the other stanc calls do.

Added test_model_format_stanc_error, using the existing bad_syntax.stan. It fails without the fix.

Fixes #882

AI disclosure: I used Claude to help investigate and prepare this change. I reviewed and understood all of it and can explain and defend it in review.

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Soujas K

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

format_stan_file runs stanc with check=True, but only caught ValueError and RuntimeError, so a stanc failure raised a raw CalledProcessError without stanc's message. Catch it and raise RuntimeError with stanc's stderr, like the other stanc calls do.

Fixes stan-dev#882

Signed-off-by: Soujas K <kudchadkarsoujas@gmail.com>

@WardBrian WardBrian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@WardBrian
WardBrian merged commit 189da21 into stan-dev:develop Nov 30, 2026
20 checks passed
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.

format_stan_file hides the stanc error message when formatting fails

2 participants