Skip to content

Conversation

@ekuboo100
Copy link

Description

Fix refactors the mergeStructs function in packages/snaps-utils/src/structs.ts to improve its robustness and prevent potential runtime errors. Previously, the function assumed that every struct in the merge would have a valid refiner function. In practice, this is not always guaranteed and could lead to errors if a struct does not implement a refiner.

With this update, the function now explicitly checks whether struct.refiner is a function before calling it. This ensures that only valid refiners are invoked, making the code more reliable and easier to maintain.

Changes

  • Updated the mergeStructs function to safely combine refiners from multiple structs.
  • Added a type check to ensure struct.refiner is a function before invoking it.

References

Regular expression
WikipediaReDoS
WikipediaTime complexity
Static Analysis for Regular Expression

@ekuboo100 ekuboo100 requested a review from a team as a code owner August 29, 2025 01:09
@Mrtenz
Copy link
Member

Mrtenz commented Sep 8, 2025

struct.refiner is required to be set by TypeScript. Do you have any way to actually reproduce a runtime error caused by this function?

@ekuboo100 ekuboo100 closed this by deleting the head repository Sep 17, 2025
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.

3 participants