Skip to content

fix(workflow): invalidate directory-items query on tag add/remove success#2255

Merged
daryllimyt merged 2 commits intomainfrom
codex/run-if-stack-2-tag-directory-items-invalidate
Mar 4, 2026
Merged

fix(workflow): invalidate directory-items query on tag add/remove success#2255
daryllimyt merged 2 commits intomainfrom
codex/run-if-stack-2-tag-directory-items-invalidate

Conversation

@daryllimyt
Copy link
Contributor

@daryllimyt daryllimyt commented Mar 4, 2026

Checklist

  • Read CONTRIBUTING.md.
  • PR title is short and non-generic (see previously merged PRs for examples).
  • PR only implements a single feature or fixes a single bug.
  • Tests passing (uv run pytest tests)?
  • Lint / pre-commits passing (pre-commit run --all-files)?

Description

This PR makes workflow tag add/remove updates reflect immediately in the directory view and simplifies workflow-tag link writes under concurrency.

  • Frontend: invalidate directory-items and workflows queries after successful workflow tag add/remove mutations.
  • Backend: replace pre-check + IntegrityError conflict handling in add_workflow_tag with PostgreSQL upsert (ON CONFLICT DO NOTHING) plus fallback fetch.
  • Behavior: add_workflow_tag remains idempotent and race-safe, without exception-driven flow for normal duplicate inserts.

Related Issues

Screenshots / Recordings

Steps to QA

  1. Run lint/type checks:
    • uv run ruff check tracecat/workflow/tags/service.py
    • uv run basedpyright tracecat/workflow/tags/service.py
  2. Run workflow-tag unit tests:
    • TRACECAT__SERVICE_KEY=test-service-key uv run pytest tests/unit/test_tags_service.py -k "TestWorkflowTagsService" -q
  3. In UI, add/remove a workflow tag and confirm directory items refresh without manual reload.

Summary by cubic

Invalidate the directory-items query on tag add/remove so the directory view updates immediately. Switch workflow tag linking to a Postgres upsert for idempotent, race-safe inserts.

  • Bug Fixes

    • Frontend: invalidate ["directory-items"] and ["workflows"] after successful tag add/remove.
  • Refactors

    • Backend: add_workflow_tag uses ON CONFLICT DO NOTHING upsert and falls back to fetch the existing link; added an idempotency unit test.

Written for commit 5af6831. Summary will update on new commits.

Copy link
Contributor Author

daryllimyt commented Mar 4, 2026

@daryllimyt daryllimyt marked this pull request as ready for review March 4, 2026 21:07
@daryllimyt daryllimyt requested a review from jordan-umusu March 4, 2026 21:08
Base automatically changed from codex/run-if-stack-1-no-agent-args-log to main March 4, 2026 21:11
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 (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tracecat/workflow/tags/service.py">

<violation number="1" location="tracecat/workflow/tags/service.py:53">
P1: The new `IntegrityError` handler is too broad: it treats all constraint failures as concurrent duplicate inserts and may raise `NoResultFound` for FK violations. Only return existing link when a row is actually found; otherwise raise a clear domain error.

(Based on your team's feedback about translating database constraint violations to explicit service-layer errors.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@daryllimyt daryllimyt force-pushed the codex/run-if-stack-2-tag-directory-items-invalidate branch from 633bcbc to 51c315b Compare March 4, 2026 21:12
Copy link
Contributor Author

daryllimyt commented Mar 4, 2026

Merge activity

  • Mar 4, 9:32 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 4, 9:32 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 4, 9:33 PM UTC: @daryllimyt merged this pull request with Graphite.

@daryllimyt daryllimyt force-pushed the codex/run-if-stack-2-tag-directory-items-invalidate branch from 8de619a to 5af6831 Compare March 4, 2026 21:32
@daryllimyt daryllimyt merged commit 6d550e6 into main Mar 4, 2026
20 checks passed
@daryllimyt daryllimyt deleted the codex/run-if-stack-2-tag-directory-items-invalidate branch March 4, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants