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

Modules don't use OC default JsonSerializerOptions #17318

Closed
arkadiuszwojcik opened this issue Jan 7, 2025 · 2 comments · Fixed by #17320
Closed

Modules don't use OC default JsonSerializerOptions #17318

arkadiuszwojcik opened this issue Jan 7, 2025 · 2 comments · Fixed by #17320

Comments

@arkadiuszwojcik
Copy link
Contributor

arkadiuszwojcik commented Jan 7, 2025

Describe the bug

Wrong (probably ASP.NET default) JsonSerializerOptions when using IOptions<JsonSerializerOptions> as module dependency.

Orchard Core version

Current master: b3d6591 (and all previous versions)

To Reproduce

Modify blog.recipe by adding step:

{
  "name": "feature",
  "enable": [
    ...
    "OrchardCore.UrlRewriting",
  ]
},
{
  "name": "UrlRewriting",
  "rules": [
    {
      "Source": "Rewrite",
      "Name": "Media rewrite rule",
      "Pattern": "^/img/(.*)$",
      "SubstitutionPattern": "/media/$1",
      "IsCaseInsensitive": true,
      "IgnoreQueryString": false,
      "SkipFurtherRules": true
    }
  ]
}

Expected behavior

Above step will fail because "rules" start from lower case but it will work when it will be replaced by "Rules". It is failing because provided JsonSerializerOptions are case sensitive. I would expect that JOptions.Default are provided.

Cause

This is happening because UrlRewritingStep dependency IOptions<JsonSerializerOptions> is not injecting default OrchardCore json serializer options. Default OC options ignore case sensivity, also those options have bunch of converters but here provided options have no converters. I suspect default ASP.NET IOptions<JsonSerializerOptions> is used instead.

@MikeAlhayek
Copy link
Member

@MikeAlhayek MikeAlhayek added this to the 3.x milestone Jan 8, 2025
Copy link
Contributor

github-actions bot commented Jan 8, 2025

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

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

Successfully merging a pull request may close this issue.

3 participants