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

Skybrud redirect not listing items #200

Open
emmashakespeare opened this issue May 6, 2024 · 2 comments
Open

Skybrud redirect not listing items #200

emmashakespeare opened this issue May 6, 2024 · 2 comments
Labels
type/bug Something isn't working

Comments

@emmashakespeare
Copy link

emmashakespeare commented May 6, 2024

Which version of Skybrud Redirects are you using? (Please write the exact version, example: 4.0.8)

13.0.4

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.2.2

Bug description

Skybrud is not able to list my redirects, I get the following error;
angular.js:15697 TypeError: r.data.items.forEach is not a function at Default.js?d=2f68a502eb666d2065edc01f70be948181cb7808:181:22 at angular.js:18075:37 at m.$digest (angular.js:19242:15) at m.$apply (angular.js:19630:13) at k (angular.js:13473:36) at v (angular.js:13730:7) at y.onload (angular.js:13635:9) 'Possibly unhandled rejection: {}'

It seems lime the items that default.js is trying to call foreach on is an object, and not an array as it should be, but that is probably caused by an earlier issue.

I tried removing the table SkybrudRedirects and the row with value 'Umbraco.Core.Upgrader.State+Skybrud.Umbraco.Redirects' in umbracokeyvalue table as suggested in other thread (#152), but without success. When i restart the app locally the umbracokeyvalue has the value 4.0.9...

Any suggesstions?

@emmashakespeare emmashakespeare added the type/bug Something isn't working label May 6, 2024
@abjerner
Copy link
Member

Hi @emmashakespeare

I'm not sure what could cause this, but this could be something like the issue described #179. Basically changing the JSON serialization options globally could affect the redirects package. The PR fixes the cases mentioned in the PR description, but I can't rule out that other changes to the global JSON settings could affect the redirects package.

So for starters, can you post back what is returned when accessing /umbraco/backoffice/Skybrud/Redirects/GetRedirects?. It's the endpoint used for the dashboard, so you need to already be logged into the backoffice in order to see it.

What I'd like to see from the endpoint is the general JSON format returned. Can you share the JSON here. The important part is the general structure and the property names, so feel free to blank out any property values that you don't feel confident sharing here on GitHub 😉

Also if you your setup involved changing the global JSON settings, could you share the steps involved for doing so here?

The state in the key value table should matter. The version number there reflects the last database migration executed by the package, which was 4.0.9. There has been any migrations in a while since the database table hasn't changed, so it will still say 4.0.9 even if you're on a much newer version.

@emmashakespeare
Copy link
Author

Hi Anders,
Sorry for the late reply, I posted this in a returning email, but perhaps it did not get to you.
Thank you for your response.
I did as you suggested and it seems like it was a global JSON setting that caused the issue like you described.

The setting I had implemented was Referencehandler.Preserve to handle circular references.
builder.Services.AddControllers().AddJsonOptions(x =>
x.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve)
Which apparently changed the items array to an object, nesting the array within the property values.

{"$id":"1","pagination":{"$id":"2","total":1,"limit":20,"offset":0,"page":1,"pages":1,"from":1,"to":1},"items":{"$id":"3","$values":[{"$id":"4","id":1,"key":"XXXX","rootNode":null,"path":"/avancerad-soek","queryString":"","url":"/avancerad-soek","destination":{"$id":"5","id":0,"key":"00000000-0000-0000-0000-000000000000","url":"/avancerad-sok","query":"","fragment":"","displayUrl":"/avancerad-sok","name":"","icon":"icon-link","type":"url","null":false,"trashed":false,"published":true,"backOfficeUrl":null,"warning":null,"culture":null,"cultureName":null},"createDate":"2024-06-12T12:13:16.603Z","updateDate":"2024-06-12T12:13:16.603Z","type":"permanent","permanent":true,"forward":false}]}}

Reference handler preserve did not help my underlying issue with circular references anyway so in my case I can remove the setting for now, but perhaps somebody else or myself will need to be able to apply it in the future?

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants