Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct user_id access logic #4595

Merged

Conversation

dhlidongming
Copy link
Contributor

This pull request addresses an issue with the user_id access logic within the CustomComponent class. Previously, there were inconsistencies in how the user_id attribute was accessed, leading to potential errors when the attribute was not set or incorrectly retrieved.
In the BaseComponent, the default setting of self._user_id to None led to inaccurate user_id retrieval:


The use of hasattr(self, '_user_id') always returned True, causing _user_id to be returned even when it was None.
@property
def user_id(self):
if hasattr(self, "_user_id"):
return self._user_id
return self.graph.user_id

This behavior resulted in a SQL error when using the SubFlow component's run_flow method, as user_id was unexpectedly None. The fix ensures user_id is correctly handled and prevents unintended None values from causing SQL execution errors.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Nov 14, 2024
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Nov 14, 2024
Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

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

Nice, @dhlidongming

Thank you.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 14, 2024
@ogabrielluiz ogabrielluiz force-pushed the fix/user-id-access-logic branch from 65cc1db to c49bc14 Compare November 14, 2024 10:14
@ogabrielluiz ogabrielluiz enabled auto-merge (squash) November 14, 2024 10:15
Copy link

codspeed-hq bot commented Nov 14, 2024

CodSpeed Performance Report

Merging #4595 will degrade performances by 30.94%

Comparing dhlidongming:fix/user-id-access-logic (c49bc14) with main (2cf3881)

Summary

❌ 2 regressions
✅ 13 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main dhlidongming:fix/user-id-access-logic Change
test_invalid_run_with_input_type_chat 13.7 ms 16.7 ms -17.51%
test_successful_run_with_output_type_debug 161.2 ms 233.4 ms -30.94%

@ogabrielluiz ogabrielluiz merged commit 0f5c31f into langflow-ai:main Nov 14, 2024
20 checks passed
diogocabral pushed a commit to headlinevc/langflow that referenced this pull request Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants