This repository was archived by the owner on May 12, 2026. It is now read-only.
fix(revit): guard against null Zone in space send and receive - #3725
Open
MayconAlvesss wants to merge 1 commit into
Open
MayconAlvesss wants to merge 1 commit into
MayconAlvesss wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Resolves a two-part bug that caused the Revit connector to fail when receiving spaces that have no zone assigned.
Closes #3524
Root cause
Space.Zonereturnsnullfrom the Revit API when a space is not assigned to any zone. The converter had two unguarded references to this property:1. On send (
SpaceToSpeckle)If
revitSpace.Zoneisnull, accessing.Namethrows immediately and the whole send operation fails.2. On receive (
SpaceToNative)The zone association block ran unconditionally. When the incoming
speckleSpace.zonewasnull(correctly serialized after this fix, or received from another host app without zone data),CreateRevitZoneIfNeededreturned the Revit document's internal default zone object. The connector then attemptedAddSpaceson it, which triggered an API error — and in the error recovery path, the existing spaces were deleted instead of updated.Changes
ConvertSpace.cs—SpaceToSpeckle: wrapped the cache/serialize call in anullguard so spaces without a zone serialize withzone = nullrather than throwing.ConvertSpace.cs—SpaceToNative: moved the entire zone-association block inside aspeckleSpace.zone != nullcheck. When no zone was intended, the connector leaves the space's zone state untouched.Testing
Manually traced through the execution path with a
Spacemock whereZoneisnull. The updated logic skips the zone block cleanly in both directions. No changes to the happy path (spaces with zones) — the logic is structurally identical to before for those cases.