Title: AttributeError: 'Restriction' object has no attribute 'endswith' when an element fails an entity requirement expressed as xs:restriction · Issue #8046 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: AttributeError: 'Restriction' object has no attribute 'endswith' when an element fails an entity requirement expressed as xs:restriction · Issue #8046 · IfcOpenShell/IfcOpenShell
X Title: AttributeError: 'Restriction' object has no attribute 'endswith' when an element fails an entity requirement expressed as xs:restriction · Issue #8046 · IfcOpenShell/IfcOpenShell
Description: Bug Description Description When an element matches the applicability but fails an entity requirement expressed as xs:restrictionxs:enumeration, ifctester crashes instead of reporting a failure. The xs:restriction form for entity names i...
Open Graph Description: Bug Description Description When an element matches the applicability but fails an entity requirement expressed as xs:restrictionxs:enumeration, ifctester crashes instead of reporting a failure. Th...
X Description: Bug Description Description When an element matches the applicability but fails an entity requirement expressed as xs:restrictionxs:enumeration, ifctester crashes instead of reporting a failure. Th...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/8046
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AttributeError: 'Restriction' object has no attribute 'endswith' when an element fails an entity requirement expressed as xs:restriction","articleBody":"### Bug Description\n\n**Description**\nWhen an element matches the applicability but fails an entity requirement expressed as \u003cxs:restriction>\u003cxs:enumeration>, ifctester crashes instead of reporting a failure. The \u003cxs:restriction> form for entity names is valid per the IDS 1.0 schema and is covered by existing test cases, but those cases only test the pass path. The fail path is untested and broken.\n\n**Steps to reproduce**\n- Use the attached IDS file against any IFC2X3 model containing at least one IfcColumn\n- Run validation via ifctester\n\n### Attachments\n\n[ifctester-restriction-bug-demo.txt](https://github.com/user-attachments/files/27587358/ifctester-restriction-bug-demo.txt)\n\nThe IDS (Renamed extension to .txt) has a broad applicability (walls and columns) and a narrower requirement (walls only). Columns match the applicability but fail the requirement, triggering the crash.\n\n**Two issues in facet.py:**\n- Restriction.__eq__ has no explicit return True at the end of the method. When all constraints pass, it returns None implicitly. This means a comparison like inst.is_a().upper() == self.name evaluates to None (falsy) even for a matching element, causing is_pass to be falsy when it should be True.\n- Because is_pass is falsy, Entity.__call__ enters the IFC2X3 type-inference block and hits line 237 (self.name.endswith(\"TYPE\")), which raises AttributeError because Restriction has no endswith method. Line 240 (f\"{self.name}TYPE\") would produce an incorrect string for the same reason.\n\n**Suggested fix:**\nAdd return True at the end of Restriction.__eq__ so matching constraints produce a truthy result. Additionally harden Entity.__call__ against non-string names:\n# Restriction.__eq__ — add explicit return\ndef __eq__(self, other):\n ...\n return True # currently missing, falls through to implicit None\n\n# Entity.__call__ — extract name_str before the IFC2X3 block\nname_str = self.name if isinstance(self.name, str) else next(\n iter(self.name.options.get(\"enumeration\", [])), \"\"\n)\nif (\n not is_pass\n and inst.file.schema == \"IFC2X3\"\n and not name_str.endswith(\"TYPE\")\n and (element_type := ifcopenshell.util.element.get_type(inst))\n):\n is_pass = element_type.is_a().upper() == f\"{name_str}TYPE\"\n\n### Debug and Error Output\n\n```true\nError\n\nFile \"ifctester/facet.py\", line 237, in __call__\n and not self.name.endswith(\"TYPE\")\nAttributeError: 'Restriction' object has no attribute 'endswith'\n```","author":{"url":"https://github.com/bsmithuk","@type":"Person","name":"bsmithuk"},"datePublished":"2026-05-11T08:48:05Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/8046"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:65727050-61f2-69f8-3b17-37a94aa43075 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 93A4:15B1DE:15EE6D:1DB91F:6B048195 |
| html-safe-nonce | cdba7884229535f0863c1c73d82c61cf95a7fb899616e07d92e5ed388fef9df8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0E0OjE1QjFERToxNUVFNkQ6MURCOTFGOjZCMDQ4MTk1IiwidmlzaXRvcl9pZCI6IjI3MjI1MTkzMDE4ODUyOTcwNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9ecf060e318d09cfd61dcc35468d3d50c98f8d549c5c7fe9cb03a1fe2b8cdd05 |
| hovercard-subject-tag | issue:4419375870 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/8046/issue_layout |
| twitter:image | https://opengraph.githubassets.com/28eb2a739e266aae803004c40c45b11ba1b59bbc5dd62996a9a9f6bd497125c7/IfcOpenShell/IfcOpenShell/issues/8046 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/28eb2a739e266aae803004c40c45b11ba1b59bbc5dd62996a9a9f6bd497125c7/IfcOpenShell/IfcOpenShell/issues/8046 |
| og:image:alt | Bug Description Description When an element matches the applicability but fails an entity requirement expressed as xs:restrictionxs:enumeration, ifctester crashes instead of reporting a failure. Th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bsmithuk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0366ddfb372682a32e92a5d86155cb08fa83e5bbe79953a968789f2f7e24c511 |
| turbo-cache-control | no-preview |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ed3f2e01f6b7672780c586c8af0e72726374d7b6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width