fix: correct user_id access logic #4595
Merged
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.
This pull request addresses an issue with the
user_id
access logic within theCustomComponent
class. Previously, there were inconsistencies in how theuser_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:langflow/src/backend/base/langflow/custom/custom_component/base_component.py
Line 31 in 2f96dbb
The use of
hasattr(self, '_user_id')
always returned True, causing_user_id
to be returned even when it was None.langflow/src/backend/base/langflow/custom/custom_component/custom_component.py
Lines 186 to 190 in 2f96dbb
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.