Title: Bonsai: guard import_item against a None geometry shape by petruconduraru · Pull Request #8640 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Bonsai: guard import_item against a None geometry shape by petruconduraru · Pull Request #8640 · IfcOpenShell/IfcOpenShell
X Title: Bonsai: guard import_item against a None geometry shape by petruconduraru · Pull Request #8640 · IfcOpenShell/IfcOpenShell
Description: Problem Editing an IfcRepresentationItem's geometry and exiting item edit mode can crash with an unhandled AttributeError instead of failing gracefully, leaving the item's mesh cleared. Root cause Exiting item edit mode re-imports geometry through tool.Geometry.import_item, which calls tool.Loader.create_generic_shape(item) and immediately passes the result to ifcopenshell.util.shape.get_vertices without checking it. The geometry kernel can legitimately return None for an item (e.g. an invalid or degenerate boolean/clipping result), which is exactly what every other caller of create_generic_shape already guards against (import_ifc.py and tool/loader.py both check the result before using it). Without the same guard here, get_vertices(None) raises an unhandled AttributeError partway through import_item, after obj.data.clear_geometry() has already run. A follow-up fix in the same branch addresses a second bug introduced by the first guard: cartesian_point_offset was only assigned inside the non-None branch's walrus operator, but is referenced unconditionally later for IfcSweptAreaSolid items, which raised UnboundLocalError in that combination. Fixed by hoisting the lookup so it's always computed. Fix Guard the create_generic_shape result: on None, log a clear error naming the offending representation item and skip only the geometry-dependent steps, instead of crashing. Testing The reporter's real .ifc file was shared privately with maintainers and wasn't available to us, so verification is synthetic: built a real IFC element and monkeypatched create_generic_shape to return None, matching the reported crash mechanism exactly (AttributeError: 'NoneType' object has no attribute 'verts_buffer', matching the reported traceback). Confirmed the fixed path completes without crashing and logs the error instead. Also confirmed the follow-up UnboundLocalError reproduces and is fixed for the IfcSweptAreaSolid case. Fixes #6693. Generated with the assistance of an AI coding tool.
Open Graph Description: Problem Editing an IfcRepresentationItem's geometry and exiting item edit mode can crash with an unhandled AttributeError instead of failing gracefully, leaving the item's mesh cleared. Roo...
X Description: Problem Editing an IfcRepresentationItem's geometry and exiting item edit mode can crash with an unhandled AttributeError instead of failing gracefully, leaving the item's mesh clea...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/pull/8640
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:62d0fbe7-a43b-95bc-38e2-309d8fc3efeb |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9514:D0CA2:14234D3:1A44814:6B05052E |
| html-safe-nonce | 05e5b0ff3479083afb5dd67088eb768100c64971f85bfec209463bad62dc234c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTE0OkQwQ0EyOjE0MjM0RDM6MUE0NDgxNDo2QjA1MDUyRSIsInZpc2l0b3JfaWQiOiI4Nzc2MDA3Njg2NzUzMTU4NDQ2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d6fa1c10a9cd2473989a53295b0a3e6df3603a7cb22098687fc069d49cd975db |
| hovercard-subject-tag | pull_request:4069047578 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/IfcOpenShell/IfcOpenShell/pull/8640/files |
| twitter:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| og:image:alt | Problem Editing an IfcRepresentationItem's geometry and exiting item edit mode can crash with an unhandled AttributeError instead of failing gracefully, leaving the item's mesh cleared. Roo... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width