Skip to content

Comments

snip source correctly for dep tracker#5613

Merged
adhami3310 merged 4 commits intomainfrom
snip-source-correctly-for-dep-tracker
Jul 24, 2025
Merged

snip source correctly for dep tracker#5613
adhami3310 merged 4 commits intomainfrom
snip-source-correctly-for-dep-tracker

Conversation

@adhami3310
Copy link
Member

fixes #5580

Copy link
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 addresses a critical bug in Reflex's dependency tracking system, specifically in how source code snippets are handled during variable analysis. The change modifies the _eval_var method in reflex/vars/dep_tracking.py to correctly extract source code when evaluating variable dependencies.

The fix specifically adjusts the string slicing logic to properly handle multi-line source code snippets. When extracting variable names from source code, it now correctly joins the source lines while preserving the complete variable names, addressing a truncation issue that was causing variables like 'loaded_experiment' to be incorrectly identified as 'loaded_experimen'.

This change is fundamental to Reflex's state management system, ensuring accurate dependency tracking and state variable access through get_var_value.

PR Description Notes:

  • The PR description could be more detailed, explaining the problem and solution more thoroughly

Confidence score: 5/5

  1. This PR is very safe to merge as it fixes a clear bug with a straightforward solution
  2. The changes are minimal, focused, and the logic correction is evident - improper string slicing is replaced with correct concatenation
  3. Key files needing attention: reflex/vars/dep_tracking.py

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 22, 2025

CodSpeed Performance Report

Merging #5613 will not alter performance

Comparing snip-source-correctly-for-dep-tracker (7e5c49e) with main (b052299)

Summary

✅ 8 untouched benchmarks

Copy link
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.

can we get a unit test added for this

@adhami3310
Copy link
Member Author

can we get a unit test added for this

the code is a bit weird, but i will try

Copy link
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.

nice

@adhami3310 adhami3310 merged commit 49570ea into main Jul 24, 2025
41 checks passed
@adhami3310 adhami3310 deleted the snip-source-correctly-for-dep-tracker branch July 24, 2025 21:43
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.

get_var_value behaves strangely.

2 participants