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

Rate plan ids are not URL-safe and breaks the site #287

Open
mxr576 opened this issue May 15, 2021 · 5 comments
Open

Rate plan ids are not URL-safe and breaks the site #287

mxr576 opened this issue May 15, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@mxr576
Copy link
Contributor

mxr576 commented May 15, 2021

Description

/ is an acceptable character in rate plan names by the Monetization API/MGMT UI. The auto-generated rate plan id also contains the / from the name. (See updated findings below in comments)

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a rate plan on Monetization UI or via API calls with / in its name, e.g.:
    image
  2. Accept the rate plan via API calls. (Why API calls? See below.)

Actual Behavior

  1. Rate plans with / in their ID are not visible on "Pricing & Plans".
  2. "Purchased plans" page of a user is broken due to the following exception:
Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "rate_plan" for route "entity.rate_plan.canonical" must match "[^/]++" ("petstore-jzbr_test/plan" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 204 of  /mnt/files/local_mount/build/web/core/lib/Drupal/Core/Routing/UrlGenerator.php).

Expected Behavior

Everything works as expected :) ™️

Screenshots

Notes

https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/using-parameters-in-routes#s-example

In fact, unlike generic Symfony routes, Drupal requires that a slug occupies a complete path part - the portion between two slashes (or everything after the last slash). If you must pass a parameter containing slashes, apply the same trick as in PathProcessorFiles.

I wonder what other entity ids are not URL-safe in monetization, like package/product bundle ids?

Version Info

1.10.0

@mxr576 mxr576 added the bug Something isn't working label May 15, 2021
@mxr576
Copy link
Contributor Author

mxr576 commented May 15, 2021

Probably simply converting path parameters with a slash to query parameters is not going to work, possibly a new URL safe identity needs to be used in paths.

@mxr576
Copy link
Contributor Author

mxr576 commented May 18, 2021

That is even worse than I expected... you can create a rate plan with almost ANY character in the rate plan name and ID inherits it as-is... no sanitization. ID is officially not URL safe. (Fun fact, you can create a rate plan like this but you cannot edit it because it also breaks the Monetization UI). @cnovak Maybe this worth sharing with engineering.
image (5)

@mxr576
Copy link
Contributor Author

mxr576 commented May 18, 2021

... and for the record, UTF8 emojies also work ™️ 🙈
image

@mxr576 mxr576 changed the title Rate plans with / in their name/id breaks the site Rate plan ids are not URL-safe and breaks the site May 18, 2021
@mxr576
Copy link
Contributor Author

mxr576 commented May 26, 2021

and this issue also causes troubles with caching

Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1270 Illegal mix of collations (ascii_general_ci,IMPLICIT), (utf8mb4_general_ci,COERCIBLE), (utf8mb4_general_ci,COERCIBLE) for operation 'in': SELECT [tag], [invalidations] FROM {cachetags} WHERE [tag] IN ( :tags__0, :tags__1 ); Array ( [:tags__0] => product_bundle:px_site_factory_❤-iqrc [:tags__1] => product_bundle:px_site_factory_❤-iqrc:values ) in Drupal\apigee_edge\Entity\Storage\EdgeEntityStorageBase->withController() (line 220 of /mnt/files/local_mount/build/web/modules/contrib/apigee_edge/src/Entity/Storage/EdgeEntityStorageBase.php).

@mxr576
Copy link
Contributor Author

mxr576 commented May 17, 2022

Bump :)

@phdhiren phdhiren removed their assignment Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants