fix(slack/run-audit): set onDemand bypass and align entitlement to siteEnrollment#2555
Open
tathagat2241 wants to merge 8 commits into
Open
fix(slack/run-audit): set onDemand bypass and align entitlement to siteEnrollment#2555tathagat2241 wants to merge 8 commits into
tathagat2241 wants to merge 8 commits into
Conversation
…teEnrollment `run audit` is an explicit one-off Slack command — it should run regardless of whether the site appears in the handler's enabled-list (without mutating that list). To make this work end-to-end: * Pass `auditContext.onDemand: true` in every `triggerAuditForSite` call emitted by `run-audit` (single audit, `audit:all`, and prerender CSV). The audit-worker uses this flag to bypass its enabled-list gate while still enforcing entitlement. * Drop the now-redundant `configuration.isHandlerEnabledForSite` precheck from the prerender CSV path so it behaves consistently with the single-audit path. * Switch the entitlement check from `tierResult.entitlement` (org-level) to `tierResult.siteEnrollment`, matching the audit-worker's downstream gate (`checkProductCodeEntitlements`). Previously a site could pass the api-service check on org-level entitlement and then be silently dropped by the audit-worker. Scheduled audit triggers do not set `onDemand`, so their behavior is unchanged — they continue to pre-filter by the handler enabled-list.
2 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This PR will trigger a patch release when merged. |
…ge get site-audit message.
rpapani
reviewed
Jun 8, 2026
rpapani
reviewed
Jun 8, 2026
rpapani
reviewed
Jun 8, 2026
rpapani
requested changes
Jun 8, 2026
rpapani
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
run auditis an explicit, one-off Slack command — it should run regardlessof whether the site appears in the handler's enabled-list, and without
mutating that list. Today, even after the audit-worker enabled-list gate is
removed (companion PR), api-service still has two issues that prevent the
end-to-end fix:
isHandlerEnabledForSiteandshort-circuits with
:x: Will not audit site '<url>' because audits of type '<type>' are disabled for this site..tierResult.entitlement(org-level), whilethe audit-worker downstream gate (
checkProductCodeEntitlements) checkstierResult.siteEnrollment(site-level). A site can pass theapi-service check and then be silently dropped in audit-worker, producing
a confusing user experience.
This PR fixes both issues and emits the
onDemand: trueflag in the SQSmessage so the audit-worker bypasses its enabled-list gate.
What changed
src/support/slack/commands/run-audit.jsauditContext: { onDemand: true }to everytriggerAuditForSitecall emitted by
run-audit— single audit,audit:all, and theprerender CSV path.
configuration.isHandlerEnabledForSiteprecheck fromthe prerender CSV path so it behaves consistently with the single-audit
path.
tierResult.entitlement→tierResult.siteEnrollmentin bothrunAuditForSiteandrunPrerenderAuditForUrls. This matches the audit-worker's downstreamgate and avoids the previously silent failure when org-level
entitlement existed but the specific site was not enrolled.
test/support/slack/commands/run-audit.test.jsentitlement→siteEnrollment.handler is disabled" test with a positive test that verifies the run
proceeds via the
onDemandbypass.auditContextcontainsonDemand: truefor single,audit:all, and prerender flows.entitlementbut nositeEnrollment⇒audit is blocked (parity with audit-worker).
Behavior matrix after this PR
onDemandrun auditsiteEnrollmentrun audit(CSV prerender)siteEnrollmentadd site/add repotriggerFromData)Configuration)Test plan
npm test— 11298 passing, 0 failing.npm run lintclean.deployed:
@spacecat run audit <site-not-in-enabled-list>for an entitled site →audit runs to completion; the site is not added to any
enabled/disabled list.
@spacecat run audit <site>for an unentitled site →:x: Will not audit site '<url>' because site is not entitled for this audit.(unchanged).
Risk
at the same time. If api-service is deployed alone, the
onDemandflagis simply ignored downstream and behavior is identical to today (the
enabled-list check still runs in audit-worker for sites in the list, and
one-off runs still fail for sites that are not — i.e. no regression, just
no fix yet).
entitlement → siteEnrollmentchange tightens the api-serviceprecheck. Any site that previously passed via org-level entitlement but
had no site enrollment was already failing silently downstream, so this
only changes where the rejection happens (api-service now returns a
clear Slack message instead of a silent worker skip).
Notes for reviewers
src/controllers/trigger/common/trigger.js)remain unchanged and still pre-filter by
isHandlerEnabledForSite. Theydo not set
onDemand, so the audit-worker bypass does not apply to them.triggerAuditForSiteinsrc/support/utils.jsalready accepts andforwards an
auditContext, so no signature change was needed there.Please ensure your pull request adheres to the following guidelines:
describe here the problem you're solving.
If the PR is changing the API specification:
yet. Ideally, return a 501 status code with a message explaining the feature is not implemented yet.
If the PR is changing the API implementation or an entity exposed through the API:
If the PR is introducing a new audit type:
Related PR: adobe/spacecat-audit-worker#2599
Related Issues
Thanks for contributing!