Skip to content

Order workflows alphabetically in credential revoke dialog#4955

Open
elias-ba wants to merge 2 commits into
mainfrom
fix/deterministic-workflow-order-credential-dialog-4954
Open

Order workflows alphabetically in credential revoke dialog#4955
elias-ba wants to merge 2 commits into
mainfrom
fix/deterministic-workflow-order-credential-dialog-4954

Conversation

@elias-ba

@elias-ba elias-ba commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

Small cleanup, not a user-visible fix.

The query behind the credential revoke-access dialog ("this credential is in use by the following workflows: ...") selects distinct workflow names with no explicit ordering, so the order was left to the database. In practice it already comes out alphabetical as a side effect of how the distinct is executed, but that is an implementation detail, not a guarantee. This adds an explicit order-by so the alphabetical order is guaranteed rather than incidental.

It also adds unit tests for project_workflows_using_credentials/1, which previously had none, covering how it groups results by project, filters by credential, and returns the names sorted.

Note: a test cannot meaningfully prove the order-by is doing anything, because the database sorts on its own at test-scale data. The added tests assert the function's contract (grouping, filtering, sorted result); they are not a regression guard for the ordering specifically.

Closes #4954

Validation steps

  1. Create a credential and share it with a project that has two or more workflows using it.
  2. Open the credential and start to revoke its access to that project.
  3. Confirm the dialog lists the affected workflows in alphabetical order.

Additional notes for the reviewer

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

The query behind the "this credential is in use by the following
workflows" confirmation had no explicit ordering, so with a distinct
select the workflow names came back in an arbitrary, unstable order.
Add an order-by so the dialog lists them alphabetically and predictably.
@github-project-automation github-project-automation Bot moved this to New Issues in Core Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Security Review ✅

  • S0 (project scoping): N/A — change only adds order_by: w.name to an existing read query in lib/lightning/workflows.ex:78; filtering behavior (project_credential_id in ^ids) is unchanged.
  • S1 (authorization): N/A — no new web-layer actions, controllers, or LiveView events; only a query-shape tweak.
  • S2 (audit trail): N/A — no writes to project/instance configuration; read-only query and test/changelog updates.

@elias-ba elias-ba requested review from midigofrank and stuartc July 8, 2026 14:58
Add unit tests for project_workflows_using_credentials/1, which had no
coverage, exercising grouping, credential filtering, and the sorted
result. Keep the credential dialog test order-insensitive, since the
ordering guarantee belongs to the query, not the rendered view. Move the
changelog note to Changed: the previous order was left to the database
rather than being broken, so this makes the alphabetical sort explicit.
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 list in credential revoke dialog has nondeterministic order

1 participant