-
Notifications
You must be signed in to change notification settings - Fork 322
feat(integrations): Include case tags in case and metrics UDFs #1817
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
base: main
Are you sure you want to change the base?
Conversation
- Implemented retrieval of tags for cases in the get_case function. - Updated CaseDurationMetric schema to include a list of associated case tags. - Modified CaseDurationService to populate case_tags from case data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| # Get tags for the case | ||
| tags = await service.tags.list_tags_for_case(case.id) | ||
| tag_reads = [CaseTagRead.model_validate(tag, from_attributes=True) for tag in tags] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fetching case tags after DB session is closed
After CasesService.with_session() exits, the DB session is closed, but service.tags.list_tags_for_case(case.id) is called afterward to build the response. This call will execute with a closed session and raise when the get_case registry action is invoked, so the new tags payload cannot be returned at all. Move the tag lookup inside the async with block or keep the session open while querying tags.
Useful? React with 👍 / 👎.
There was a problem hiding this 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 3 files
Prompt for AI agents (all 1 issue)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/tracecat-registry/tracecat_registry/core/cases.py">
<violation number="1" location="packages/tracecat-registry/tracecat_registry/core/cases.py:368">
P0: Using `service` outside its `async with` context manager will cause a runtime error. The database session is closed after the `async with CasesService.with_session() as service:` block ends. Move this code inside the context manager block.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| ) | ||
|
|
||
| # Get tags for the case | ||
| tags = await service.tags.list_tags_for_case(case.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P0: Using service outside its async with context manager will cause a runtime error. The database session is closed after the async with CasesService.with_session() as service: block ends. Move this code inside the context manager block.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/tracecat-registry/tracecat_registry/core/cases.py, line 368:
<comment>Using `service` outside its `async with` context manager will cause a runtime error. The database session is closed after the `async with CasesService.with_session() as service:` block ends. Move this code inside the context manager block.</comment>
<file context>
@@ -363,6 +364,10 @@ async def get_case(
)
+ # Get tags for the case
+ tags = await service.tags.list_tags_for_case(case.id)
+ tag_reads = [CaseTagRead.model_validate(tag, from_attributes=True) for tag in tags]
+
</file context>
Summary by cubic
Expose case tags in case details and duration metrics to enable filtering and grouping by tag in UDFs and dashboards.
Written for commit 85c4695. Summary will update automatically on new commits.