Skip to content

prevent tag special props from being a shared mutable reference#5640

Merged
adhami3310 merged 2 commits into
mainfrom
khaleel/eng-7129-vite-esbuild-fails-if-page-includes-two-plotly-graphs-of-the
Jul 30, 2025
Merged

prevent tag special props from being a shared mutable reference#5640
adhami3310 merged 2 commits into
mainfrom
khaleel/eng-7129-vite-esbuild-fails-if-page-includes-two-plotly-graphs-of-the

Conversation

@adhami3310
Copy link
Copy Markdown
Member

ideally this guy should be mutable

@linear
Copy link
Copy Markdown

linear Bot commented Jul 30, 2025

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR fixes a critical shared mutable reference bug in the component rendering system. The issue occurs in the Component._render() method where special_props was being passed by reference to Tag objects, causing multiple component instances to inadvertently share the same list.

The fix changes special_props=self.special_props to special_props=self.special_props.copy() on line 967 of reflex/components/component.py. This ensures each Tag gets its own independent copy of the special props list, preventing cross-component contamination.

This change addresses a classic Python mutable default argument issue. The special_props field is defined as a list with a default factory, but when creating Tag objects, the same list reference was being shared across multiple instances. This likely manifested when rendering multiple components (like plotly graphs mentioned in the branch name) where modifications to one component's special_props would affect other components.

The fix integrates seamlessly with the existing component architecture without changing any APIs or breaking existing functionality. It's a defensive programming practice that prevents subtle bugs in component rendering.

Confidence score: 5/5

  • This is an extremely safe fix that prevents a serious shared state bug with no downside
  • The change is minimal, well-targeted, and follows Python best practices for avoiding mutable reference issues
  • No files need additional attention - this is a straightforward defensive copy operation

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jul 30, 2025

CodSpeed Performance Report

Merging #5640 will not alter performance

Comparing khaleel/eng-7129-vite-esbuild-fails-if-page-includes-two-plotly-graphs-of-the (1e1e9e4) with main (1aafe9a)

Summary

✅ 8 untouched benchmarks

Copy link
Copy Markdown
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥🤘🦾

@adhami3310 adhami3310 merged commit 3720b7a into main Jul 30, 2025
40 of 41 checks passed
@adhami3310 adhami3310 deleted the khaleel/eng-7129-vite-esbuild-fails-if-page-includes-two-plotly-graphs-of-the branch July 30, 2025 02:01
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.

Vite esbuild fails if page includes two plotly graphs of the same type

2 participants