Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@topher-lo
Copy link
Contributor

@topher-lo topher-lo commented Dec 18, 2025

Summary by cubic

Expose case tags in case details and duration metrics to enable filtering and grouping by tag in UDFs and dashboards.

  • New Features
    • get_case now returns tags on CaseRead.
    • Added case_tags (list of tag refs) to CaseDurationMetric.
    • Populated case_tags from case data in the duration metrics formatter.

Written for commit 85c4695. Summary will update automatically on new commits.

- 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.
@topher-lo topher-lo added the core-actions Improvements to core Tracecat actions label Dec 18, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines +367 to +369
# 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]

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

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 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)
Copy link
Contributor

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

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>
Fix with Cubic

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

Labels

core-actions Improvements to core Tracecat actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants