Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(241800): Prevent redirection on not-found, keeping URL the same #967

Closed
wants to merge 15 commits into from

Conversation

DrewAire
Copy link
Collaborator

@DrewAire DrewAire commented Feb 20, 2025

Overview

Addresses ticket #241800

Adds a new controller filter MaintainUrlOnKeyNotFoundAttribute which looks for KeyNotFoundExceptions returned from the Contentful data context and returns the NotFoundError view page if content is missing. Doing it this way achieves the desired goal of leaving the user at the URL where it failed so that they can refresh.

I also fixed some of the warnings that pop up in GitHub tests.

Changes

Major

  • MaintainUrlOnKeyNotFoundAttribute filter added at a global level to show the NotFoundError view when we pick up a KeyNotFoundException
  • ContentController.Index no longer redirects when the slug is empty, instead raising a KeyNotFoundException which routes through the new filter
  • PagesController.GetByRoute no longer redirects when the page is null, instead returning the NotFoundError view

Minor

  • GetLatestResponsesQuery class no longer reassigns the db value to a private readonly variable
  • Removed uses of magic strings e.g. in UserHelper.cs where the constant string can just reference ClaimConstants.Organisation
  • Removed properties which are already defined in the parent class in ContentItem and ContentItemBase
  • Fixed warning on establishmentId string in OnUserInformationReceivedEvent.cs
  • Changes to ServiceExceptionHandlerMiddleware to make better use of dependency injection instead of pulling services out in Program.cs and passing them down
  • Renamed some test variables from sut to controller

Non-functional changes (e.g. documentation)

  • Removed references to Moq - now NSubstitute
  • Updated all packages

How to review the PR

@jag-nahl-airelogic, this is going to be a pain to test. I managed to stop the entities getting returned by adding the following in ContentfulRepository on line 36:

        var missingContent = false;
        if (missingContent)
        {
            return [];
        }

Checklist

Delete any rows that do not apply to the PR.

  • [v] Title uses Angular commit convention
  • [v] PR targets development branch
  • [v] Unit tests have been added/updated
  • [v] Documentation has been updated where relevant

Drew MORGAN added 2 commits February 19, 2025 14:35
@DrewAire DrewAire closed this Feb 27, 2025
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