Skip to content

fix(recommendations): scoped users see 'Recommendations refresh failed: permission denied' after the stale-data auto-refresh became scope-gated #619

Open

Description

@cristim

Found in the review of PR #615 (#520 slice: POST /api/recommendations/refresh now requires an unrestricted account scope because it runs a global collection and takes the single global in-flight marker). The frontend auto-refreshes stale data: triggerAutoRefreshIfStale (frontend/src/recommendations.ts ~317; callers loadRecommendations ~670 and dashboard.ts ~227) fires for any user with view:recommendations when the data is older than 24h. For a scoped user it now shows an info toast 'Refreshing recommendations…' then an error toast 'Recommendations refresh failed: permission denied: refreshing recommendations covers every account and requires unrestricted account access', on both the Home dashboard and Opportunities. The data still loads; the message is misleading (an automatic action the user never asked for is reported as failed, with no next step).

The frontend cannot tell scope today: User has only groups and effectivePermissions and /auth/me/permissions carries no scope field.

Acceptance: either add a scope field (or an 'unrestricted' flag) to the permissions/me response and skip the auto-refresh for scoped users, or handle a 403 on the AUTO path quietly (dismiss the in-flight toast, no error toast, console log) without hiding genuine 403s such as a missing view permission; with a recommendations.test.ts case (jest, tests around ~1622-1680 cover triggerAutoRefreshIfStale). Also decide whether scoped users should get a per-account refresh (needs a new CollectRecommendations contract: account filter plus a per-account marker). Related: #520, #615, #617.

Activity

  1. IAmJSD commented on Oct 19, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  2. self-assigned this
    on Oct 19, 2026
  3. IAmJSD commented on Oct 27, 2026

    @IAmJSD
    Collaborator

    Status update (2026-10-27, checked against main at 7b86e38): What is left is frontend UI work, which cristim owns, so no PR from us.

    The backend half is done: /auth/me/permissions now reports unrestricted_account_access (#1155). The frontend still auto-refreshes stale recommendations for scoped users, who then see a 'permission denied' toast.

    Left / blocked on: Frontend (cristim): read unrestricted_account_access in getUserPermissions, skip triggerAutoRefreshIfStale (frontend/src/recommendations.ts:350) for scoped users, and add a recommendations.test.ts case. Optional owner decision: a per-account refresh for scoped users, which needs a new CollectRecommendations contract. Recommendation: not now.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions