Skip to content

Header policy: catch the parser's real exception - #340

Open
Ghesselink wants to merge 2 commits into
developmentfrom
fix-header-policy-except
Open

Ghesselink wants to merge 2 commits into
developmentfrom
fix-header-policy-except

Conversation

@Ghesselink

Copy link
Copy Markdown
Contributor

Cleanup:
validate_header.py catches ifcopenshell.simple_spf.SyntaxError, which does not exist; the parser raises
CollectedValidationErrors. So whenever the try block fails, the script dies with an AttributeError instead
of returning the intended {"validation_errors": ["syntax_error"]}.

Impact is small: the header-syntax task runs first and skips the header task on an unparsable header, so
in the pipeline this path is not reached.

@Ghesselink Ghesselink changed the title Header policy: catch the parser's real exception so an unparsable hea… Header policy: catch the parser's real exception Oct 29, 2026
file = ifcopenshell.simple_spf.open(filename, only_header=True)
header = HeaderStructure(file=file)
except ifcopenshell.simple_spf.SyntaxError:
except ifcopenshell.simple_spf.CollectedValidationErrors:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not very pretty. Maybe we should adapt the submodule so that CollectedValidationErrors inherits from SyntaxError or some other abstract exception. It feels a bit leaky to really catch something so specific. Otherwise it sounds like it should not be an exception at all, but more like a report that is returned. See if you feel like it. Not really important enough to justify a lot of work.

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.

2 participants