Should respect jsonapi.base_path container parameter override

Created on 29 March 2023, over 1 year ago
Updated 1 September 2023, over 1 year ago

Problem/Motivation

When JSON:API Extras module is enabled then it looks like it takes over the control on the JSONAPI base path setting. So even if there was a parameter override set for the jsonapi.base_path container parameter (according to the docs ), it rolls it back to /jsonapi.

Background story: we have enabled JSONAPI Extras for the field enhancer feature, but we did not expect that it starts overriding existing "hardenings".

Steps to reproduce

* Set up a jsonapi.base_path: /foo parameter override in service.yml
* Enable the JSONAPI Extras module
* The JSONAPI base path rolls back to /jsonapi instead of staying on /foo.

Proposed resolution

Do not override the JSONAPI base path when a path override already exits. Also disable the related configuration option.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇭🇺Hungary mxr576 Hungary

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mxr576
  • @mxr576 opened merge request.
  • Status changed to Needs review over 1 year ago
  • 🇭🇺Hungary mxr576 Hungary

    Okay, so tests are passing on D9. My gut says they are not broken on D10 due to the changes that I have made... so needs review.

  • 🇳🇱Netherlands bbrala Netherlands

    Hmm, i wonder, another approach to fixing this might be jsonapi extra's not writing the the parameter if the setting is not filled. But it seems the current form does not allow that. Therefor looking at some setting or parameter to see if we need to do work as extra's would be fine.

    I think that this fix in its current is a little opague since it just magically stops overwriting. I would probably opt for an explicit setting to disable the path override in the settings form? Although UX wise that is a little weird. But in regards to migration of old settings is probably the easiest implementation path.

  • Status changed to Needs work over 1 year ago
  • 🇭🇺Hungary mxr576 Hungary

    I would probably opt for an explicit setting to disable the path override in the settings form?

    How that would work/solve the problem in a scenario when jsonapi.base_path parameter was already defined in services.yml _before_ JSONAPI Extras module was enabled? Should the default value of "disable the path override" setting would be TRUE? Would not that be even more confusing? :)

    since it just magically stops overwriting.

    If I understand your comment right then you are concerned about the upgrade path for existing projects where JSONAPI Extras should not have overridden the path that was defined in jsonapi.base_path parameter, but it did...

    Since this problem could be only solved with more magic... (like a BC config setting that tries to guess whether this was true or not), I'd say since this is a bug fix, the release notes should explain developers that if they experience any issues after the update look for a potential base path configuration mismatch between JSONAPI Extra's settings and services.yml.

    Would you accept that or you would rather see a BC setting instead?

  • 🇳🇱Netherlands bbrala Netherlands

    How that would work/solve the problem in a scenario when jsonapi.base_path parameter was already defined in services.yml _before_ JSONAPI Extras module was enabled? Should the default value of "disable the path override" setting would be TRUE? Would not that be even more confusing? :)

    This is a valid point. To be honest an opt-in approach to the path override does make a lot of sense really. I understand from an initial implementation standpoint that this module started with just overriding and using the default. I do understand this might make implementation a little harder since it would need to also add a update hook to set the setting right.

    This would also bring the path override in line with the resourceoverrides which need to be explicitly enabled.

    If I understand your comment right then you are concerned about the upgrade path for existing projects where JSONAPI Extras should not have overridden the path that was defined in jsonapi.base_path parameter, but it did...

    Since this problem could be only solved with more magic... (like a BC config setting that tries to guess whether this was true or not), I'd say since this is a bug fix, the release notes should explain developers that if they experience any issues after the update look for a potential base path configuration mismatch between JSONAPI Extra's settings and services.yml.

    Would you accept that or you would rather see a BC setting instead?

    I do think the end goal should be to enable path override explicitly but this can wait for a new major. But the more i think of it i think the current implementation is fine for now. I do agree the release notes would need a proper explaination should things change. But i'm not too worries there will be many unforseen concequences for people after upgrading.

    So for now, lets just get this there.

    The failures are jsonapi_defaults being not so nice it seems. I've not seen issues running this on a d10 install.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    14 pass, 2 fail
  • 🇭🇺Hungary mxr576 Hungary

    Okay, so if I understand it well the change as-is is acceptable, right? It just requires a detailed release note about the "unexpected" outcomes.

    I can ask one of my colleagues to RTBC this because we have been using this patch on some projects already for a while.

    The failures are jsonapi_defaults being not so nice it seems. I've not seen issues running this on a d10 install.

    This patch fixes that unrelated failure based on my testing: https://www.drupal.org/project/jsonapi_extras/issues/3349731#comment-150... 🐛 InvalidArgumentException: Expected a scalar value as a 2nd argument to "Symfony\Component\HttpFoundation\InputBag::get()", "array" given. Fixed

  • Status changed to Needs review over 1 year ago
  • Status changed to RTBC over 1 year ago
  • Status changed to Needs work over 1 year ago
  • 🇳🇱Netherlands bbrala Netherlands

    There are some style issues and we kinda need to use dependency injection :)

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    17 pass
  • 🇳🇱Netherlands bbrala Netherlands

    Applied the style fixes at lease

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    17 pass
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    17 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    17 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    17 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    17 pass
  • Status changed to Fixed over 1 year ago
  • 🇳🇱Netherlands bbrala Netherlands

    Greate work <3

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024