Skip to content

Conversation

@awilfox
Copy link

@awilfox awilfox commented Dec 17, 2025

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.

  • New Features
    • chainlit_data_layer.get_step: joins Feedback and returns a StepDict or None.
    • sql_alchemy.get_step: mirrors behavior, maps fields, respects showInput, and returns optional FeedbackDict.
    • No schema changes; read-only queries only.

Written for commit 32f5d82. Summary will update automatically on new commits.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. data layer Pertains to data layers. labels Dec 17, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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&#39;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

query=steps_feedbacks_query, parameters={"step_id": step_id}
)

if not isinstance(steps_feedbacks, list):
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 17, 2025

Choose a reason for hiding this comment

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

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&#39;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={&quot;step_id&quot;: 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

This is useful for pulling message metadata from an on_feedback
callback, for instance.
auto-merge was automatically disabled December 19, 2025 03:21

Head branch was pushed to by a user without write access

@awilfox awilfox force-pushed the awilfox/add-step-fetch-to-data-layer branch from abbdfa9 to 32f5d82 Compare December 19, 2025 03:21
@awilfox
Copy link
Author

awilfox commented Dec 19, 2025

v2:

  • Fixed ruff and mypy findings on the SQL Alchemy change. (Sorry; forgot to run them again locally after changing it a bit.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data layer Pertains to data layers. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants