Skip to content

feat(suggestions): allow OUTDATED status in auto-fix allowlist#2425

Open
FentPams wants to merge 4 commits into
mainfrom
xfeng/allow-outdated-autofix
Open

feat(suggestions): allow OUTDATED status in auto-fix allowlist#2425
FentPams wants to merge 4 commits into
mainfrom
xfeng/allow-outdated-autofix

Conversation

@FentPams
Copy link
Copy Markdown
Contributor

@FentPams FentPams commented May 15, 2026

Summary

Two gaps that blocked the end-to-end re-deploy flow for OUTDATED alt-text suggestions:

Gap 1 — Autofix gate rejected OUTDATED
The autofix controller only accepted NEW | PENDING_VALIDATION. When a V2 re-detected suggestion (FIXED→OUTDATED after the projector ran) reached the deploy
button, the api-service returned 400 inside a 207. The UI showed a success toast while nothing re-deployed — silent failure.

Gap 2 — Grant revocation blocked PLG customers
STALE_STATUSES included OUTDATED, so the grant cycle revoked the token grant when a suggestion flipped to OUTDATED. PLG customers then hit a 403
("suggestions are not granted") when trying to re-deploy, even after Gap 1 is fixed.

Changes

  • src/controllers/suggestions.js — add OUTDATED to the autofix allowlist (Gap 1)
  • src/support/grant-suggestions-handler.js — update isRevocable to distinguish V1 vs V2 OUTDATED:
    • V2 re-detected (recommendations[0].previousDeployment present): grant preserved — customer can re-deploy
    • V1 legacy (no stamp): grant revoked as before — stale book-keeping, free the token slot

Context

The V2 projection pipeline (mystique PR #1974/#1982) stamps previousDeployment on suggestions it flips FIXED→OUTDATED after genuine re-detection. The UI
(PR #1914, #1925) uses this stamp to route OUTDATED rows to the Current + Deployed tabs with a "Re-detected" pill. This PR closes the two remaining
server-side gaps so the re-deploy actually works end-to-end.

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description. Or if there's no issue created, make sure you
    describe here the problem you're solving.
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

If the PR is changing the API specification:

  • make sure you add a "Not implemented yet" note the endpoint description, if the implementation is not ready
    yet. Ideally, return a 501 status code with a message explaining the feature is not implemented yet.
  • make sure you add at least one example of the request and response.

If the PR is changing the API implementation or an entity exposed through the API:

  • make sure you update the API specification and the examples to reflect the changes.

If the PR is introducing a new audit type:

  • make sure you update the API specification with the type, schema of the audit result and an example

Related Issues

Thanks for contributing!

OUTDATED alt-text suggestions are re-detections of previously-FIXED
rows where the producer found the issue still present on the live URL
(after the publish-lag reset gate). The experience-success-studio-ui
PR #1914 surfaces OUTDATED in the Current tab so customers can retry
the deploy, but the auto-fix controller's status gate only accepted
NEW and PENDING_VALIDATION — silently rejecting OUTDATED with 400
inside a 207 response. The UI today treats 2xx as success, so the
customer sees a "Success" toast while nothing actually re-deploys.

This 3-line allowlist relaxation closes the gap. The rest of the
round-trip is already status-agnostic:

  - bulkUpdateStatus is source-status-agnostic (verified in
    spacecat-shared-data-access: no state machine, no transition
    rules, no hooks — just enum membership check on the target value)
  - autofix-worker queries by opportunity_id + IN_PROGRESS, origin
    status is invisible to it
  - alt-text handler reads recommendations[0].altText, writes alt,
    transitions IN_PROGRESS → FIXED — status-agnostic
  - mystique projector and publish-lag reset gate are timestamp-driven,
    not status-driven

So OUTDATED → IN_PROGRESS → (apply) → FIXED is now the supported flow.

Tests:
  - Updated existing assertion to reflect new error message
  - Added new test asserting OUTDATED is accepted, bulkUpdateStatus
    transitions it to IN_PROGRESS, and the 207 response reports
    success=1 / failed=0

All 404 suggestions controller tests pass, no regressions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

V2 re-detected OUTDATED rows (previousDeployment stamp present in
recommendations[0]) represent actionable work — PLG customers must
be able to re-deploy them. The grant revocation predicate previously
treated all OUTDATED as stale, revoking the token grant and causing
a 403 on re-deploy.

Only revoke OUTDATED grants that lack the previousDeployment stamp
(V1 legacy windowing rows), which are genuinely stale book-keeping.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

This PR will trigger a minor release when merged.

@FentPams FentPams force-pushed the xfeng/allow-outdated-autofix branch from fb63148 to 67996a1 Compare May 18, 2026 16:52
@FentPams FentPams requested a review from jeddiec May 18, 2026 16:53
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant