Guard against undefined events in getAllEvents and identifyData#991
Closed
ioxde wants to merge 2 commits intocodama-idl:mainfrom
Closed
Guard against undefined events in getAllEvents and identifyData#991ioxde wants to merge 2 commits intocodama-idl:mainfrom
ioxde wants to merge 2 commits intocodama-idl:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 33290af The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Author
|
I ran into this issue again even with these changes. I think the correct fix is either normalizing the data structure as mentioned above or changing the events type to Closing this- let me know if you'd like me to follow up with a different PR. |
This was referenced Apr 15, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I ran into this issue after rebasing my fork to 35516d4. If you want me to merge the commits into one let me know.
getAllEventsreturns[undefined]andidentifyDatathrows whenprogram.eventsis undefined. ProgramNodes from JSON deserialization or pre-events codama trees won't have the field.The visitors already guard with
(node.events ?? [])but I also added tests for them.NOTE: Same gap exists in all
getAll*functions. They all do bareprogram.Xwithout?? [].I think the root cause is
rootNode(). It passes programs through without callingprogramNode(), so raw JSON objects keepundefinedfor missing fields likeevents. The?? []guards are the safe incremental fix. A deeper fix would be normalizing throughprogramNode()inrootNode(), but unsure if that has side-effectsHappy to update this PR if you want