Skip to content

Introduce TokenDisabled event for WorkflowRuns#19431

Open
hellcp-work wants to merge 1 commit intoopenSUSE:masterfrom
hellcp-work:token-notif
Open

Introduce TokenDisabled event for WorkflowRuns#19431
hellcp-work wants to merge 1 commit intoopenSUSE:masterfrom
hellcp-work:token-notif

Conversation

@hellcp-work
Copy link
Copy Markdown
Contributor

Fixes #18886

@github-actions github-actions bot added the Frontend Things related to the OBS RoR app label Mar 13, 2026
receiver_roles :token_executor, :token_member
delegate :members, to: :token, prefix: true

self.notification_explanation = 'Receive notifications for disabled workflow tokens.'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess this begs the question that people probably want to know about other Token state changes too...

receiver_roles :token_executor, :token_member
delegate :members, to: :token, prefix: true

self.notification_explanation = 'Receive notifications for disabled workflow tokens.'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
self.notification_explanation = 'Receive notifications for disabled workflow tokens.'
self.notification_explanation = 'Receive a notification when a workflow token is disabled.'

self.notification_explanation = 'Receive notifications for disabled workflow tokens.'

def subject
"Workflow Token '#{token.description}' was disabled"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"Workflow Token '#{token.description}' was disabled"
"Workflow Token '#{token.id}' was disabled"

@@ -0,0 +1,7 @@
%p
The Workflow Token
'#{Token.find(event['token_id']).description}'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

description might be nil...

%p
The Workflow Token
'#{Token.find(event['token_id']).description}'
was disabled.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
was disabled.
was disabled because we encountered authentication problems while reporting workflow status back to the SCM. Please check your setup.

self.notification_explanation = 'Receive notifications for workflow tokens disabled automatically.'

def subject
"Workflow Token '#{token.description}' was disabled automatically"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"Workflow Token '#{token.description}' was disabled automatically"
"Workflow Token '#{token.id}' was disabled automatically"

receiver_roles :token_executor, :token_member
delegate :members, to: :token, prefix: true

self.notification_explanation = 'Receive notifications for workflow tokens disabled automatically.'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
self.notification_explanation = 'Receive notifications for workflow tokens disabled automatically.'
self.notification_explanation = 'Receive notifications when a workflow token gets disabled.'

%p
The Workflow Token
'#{Token.find(event['token_id']).description}'
was automatically disabled due to a failed call to the SCM.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
was automatically disabled due to a failed call to the SCM.
was automatically disabled due to authorization problems when reporting workflow status to Gihub/Gitlab/Gitea. Please check your setup.

@@ -0,0 +1,3 @@
The Workflow Token '<%= Token.find(event['token_id']).description %>' was automatically disabled due to a failed call to the SCM.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
The Workflow Token '<%= Token.find(event['token_id']).description %>' was automatically disabled due to a failed call to the SCM.
The Workflow Token '<%= Token.find(event['token_id']).description %>' was automatically disabled due to authorization problems when reporting workflow status to Gihub/Gitlab/Gitea. Please check your setup.

@hellcp-work hellcp-work force-pushed the token-notif branch 2 times, most recently from e6c2648 to f7747f7 Compare March 16, 2026 13:25
@github-actions github-actions bot added the Test Suite / CI 💉 Things related to our tests/CI label Mar 16, 2026
Comment on lines +49 to +51
token_enabled = token.enabled
if token.update(xml_attributes)
Event::TokenDisabled.create(id: token.workflow_runs.first&.id, token_id: token.id, user_id: @user.id, reason: "Disabled by #{@user.login}.") if token_enabled && !token.enabled
Copy link
Copy Markdown
Member

@hennevogel hennevogel Mar 16, 2026

Choose a reason for hiding this comment

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

This sounds like Token (callback) code to me to be honest.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm worried about triggering this twice in case of the detected automated token disablement

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What exactly are you worried about?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we do it when the change is triggered on the after save level and then trigger it on the change happens in the automated way in another model, we end up with two events for the same action

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why would you do both?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To know what the reason for the change was

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See the commit_opts pattern in Project for instance...

@hellcp-work hellcp-work force-pushed the token-notif branch 2 times, most recently from 405443f to e7b0054 Compare March 19, 2026 12:09
@@ -0,0 +1,52 @@
module Event
class TokenDisabled < Base
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Time to rename this event and also notify when the token is enabled again.

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

Labels

Frontend Things related to the OBS RoR app Test Suite / CI 💉 Things related to our tests/CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Token Circuit Breaker Notification

3 participants