Skip to content

Avoid exception when fetching auth methods for an unpersisted trigger#4820

Open
midigofrank wants to merge 1 commit into
mainfrom
4819-unsaved-trigger-exception
Open

Avoid exception when fetching auth methods for an unpersisted trigger#4820
midigofrank wants to merge 1 commit into
mainfrom
4819-unsaved-trigger-exception

Conversation

@midigofrank
Copy link
Copy Markdown
Collaborator

Description

request_trigger_auth_methods used Repo.get! to load the trigger, which raised Ecto.NoResultsError when the trigger only existed in the collaborative editor document and was not yet persisted.
This PR queries the webhook auth methods directly via the trigger association so an unpersisted trigger returns an empty list instead.

Fixes #4819

Validation steps

This is hard to reproduce given it happens in an async task and therefore doesn't bubble up to the UI.

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

request_trigger_auth_methods used Repo.get! to load the trigger, which
raised Ecto.NoResultsError when the trigger only existed in the
collaborative editor document and was not yet persisted. Query the
webhook auth methods directly via the trigger association so an
unpersisted trigger returns an empty list instead.

Fixes #4819
@github-project-automation github-project-automation Bot moved this to New Issues in Core Jun 1, 2026
@midigofrank midigofrank marked this pull request as ready for review June 1, 2026 10:45
@midigofrank midigofrank requested a review from stuartc June 1, 2026 10:46
@midigofrank midigofrank self-assigned this Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Security Review ✅

  • S0 (project scoping): PASS — workflow_channel.ex:515-525 now derives project_id from socket.assigns.project.id (set at authenticated join) and filters webhook_auth_methods via wam.project_id == ^project_id joined with triggers, so a spoofed cross-project trigger_id returns an empty list instead of leaking auth methods.
  • S1 (authorization): N/A — no new web-layer write actions; the read handler's gating model is unchanged by this PR.
  • S2 (audit trail): N/A — read-only query, no config-resource writes.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.3%. Comparing base (6331486) to head (40bf94f).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #4820   +/-   ##
=====================================
  Coverage   90.3%   90.3%           
=====================================
  Files        442     442           
  Lines      22545   22545           
=====================================
+ Hits       20350   20356    +6     
+ Misses      2195    2189    -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

Workflow channel raises an exception when fetching trigger auth methods for an unpersisted trigger

1 participant