feat: Add ability to fetch step from data layer#2729
Merged
hayescode merged 1 commit intoChainlit:mainfrom Jan 8, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="backend/chainlit/data/sql_alchemy.py">
<violation number="1" location="backend/chainlit/data/sql_alchemy.py:451">
P1: Missing empty list check before accessing `steps_feedbacks[0]`. If the step doesn't exist, the query returns an empty list and this will raise an `IndexError`. Follow the existing pattern used elsewhere in this file (e.g., `get_user`, `get_element`).</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
backend/chainlit/data/sql_alchemy.py
Outdated
| query=steps_feedbacks_query, parameters={"step_id": step_id} | ||
| ) | ||
|
|
||
| if not isinstance(steps_feedbacks, list): |
Contributor
There was a problem hiding this comment.
P1: Missing empty list check before accessing steps_feedbacks[0]. If the step doesn't exist, the query returns an empty list and this will raise an IndexError. Follow the existing pattern used elsewhere in this file (e.g., get_user, get_element).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/chainlit/data/sql_alchemy.py, line 451:
<comment>Missing empty list check before accessing `steps_feedbacks[0]`. If the step doesn't exist, the query returns an empty list and this will raise an `IndexError`. Follow the existing pattern used elsewhere in this file (e.g., `get_user`, `get_element`).</comment>
<file context>
@@ -415,6 +415,83 @@ async def delete_step(self, step_id: str):
+ query=steps_feedbacks_query, parameters={"step_id": step_id}
+ )
+
+ if not isinstance(steps_feedbacks, list):
+ return None
+
</file context>
Suggested change
| if not isinstance(steps_feedbacks, list): | |
| if not isinstance(steps_feedbacks, list) or not steps_feedbacks: |
✅ Addressed in abbdfa9
090982f to
abbdfa9
Compare
hayescode
approved these changes
Dec 19, 2025
auto-merge was automatically disabled
December 19, 2025 03:21
Head branch was pushed to by a user without write access
abbdfa9 to
32f5d82
Compare
Contributor
Author
|
v2:
|
|
This PR is stale because it has been open for 14 days with no activity. |
This is useful for pulling message metadata from an on_feedback callback, for instance.
32f5d82 to
06c891d
Compare
Contributor
Author
|
v3: Rebased atop current Let me know if anything further is required to merge this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is useful for pulling message metadata from an on_feedback callback, for instance.
Summary by cubic
Add get_step to the data layer to fetch a step by ID with its associated feedback. This enables pulling message metadata in on_feedback callbacks.
Written for commit 06c891d. Summary will update on new commits.