Skip to content

629 Follow-up: Prevent static hero fallback from bypassing status gating #682

Description

@patinen

Enhancement Description

  • Update the existing hero fallback logic so that a successful Directus response with no Published heroes does not fall back to static hero data.
  • Why improve it?**: Hero status gating introduced in Status gating for heroes #629 ensures that only heroes with status = Published are returned from Directus. However, some existing hero views and helpers fall back to static hero data when Directus returns an empty result. In edge cases, this can make Draft or Archived heroes publicly visible again and effectively bypass the status gating.

🌟 Benefits of the Enhancement

  • Prevents unfinished or archived hero content from appearing publicly when it should be hidden.
  • Keeps the new status workflow reliable and makes a clear distinction between a valid empty Directus response and an actual Directus request failure. This also makes the fallback behavior easier to reason about and maintain.

🛠️ Proposed Implementation

  • Technical Details:

    • Treat a successful Directus response with no Published heroes as a valid result.

    • Do not use static hero data when the Directus request succeeds but returns an empty list or no matching Published hero.

    • Keep static fallback only for actual Directus failures or unavailable Directus, if fallback behavior is still desired.

    • Review the existing fallback logic in:

      • HeroManager.getHeroBySlugAsync()
      • HeroManager.getAllHeroesFromDirectus()
      • Defense gallery views using useGetHeroGroupsQuery()
      • Hero detail page loading and navigation
  • Implementation Plan:

    1. Separate successful empty responses from failed Directus requests.
    2. Prevent undefined / empty Published results from automatically falling back to static hero data.
    3. Ensure a Draft or Archived hero accessed directly by slug results in NotFound instead of static fallback.
    4. Ensure gallery/group views stay empty when Directus successfully returns no Published heroes.
    5. Add regression tests for the fallback behavior.

📎 Additional Information

The desired behavior is that a successful empty Directus response remains empty, while static fallback is only used for actual Directus failures.

Activity

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

Metadata

Metadata

Assignees

Labels

enhancementFor improvements to existing features

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions