Problem/Motivation
Entering a valid relative path starting with leading / in Akamai Cache Control form is throwing below exception:
InvalidArgumentException: The URL //node/1 is not managed by Akamai. Try setting your Akamai base url. in Drupal\akamai\AkamaiClientBase->purgeUrls() (line 252 of modules/contrib/akamai/src/AkamaiClientBase.php).
On debugging, I found that the submitForm function in CacheControlForm.php is appending a / at the start of each path($urls_to_clear[] = trim('/' . $path);) before calling $this->akamaiClient->purgeUrls($urls_to_clear). Hence every relative input path with a leading /, Ends up having two leading // and the same gets passed to purgeUrls() which in turn is throwing exception.
Steps to reproduce
- Login as an admin on the site.
- Configure the akamai module at
/admin/config/akamai/configand make sure you enter a valid Base Path. - Go to the path
/admin/config/akamai/cache-clear - In the "Paths/URLs/CPCodes" form element, Enter a valid node's relative path(Example: /node/1).
- In the "Purge Method" form element, Ensure "Url" radio is selected.
- Click on "Start Refreshing Content" submit button.
- You should get the HTTP 500 error.
Proposed resolution
- In the
validateForm()function, Set error if any of the relative path is starting with a leading/
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3213827-Exception_Url_Not_Managed_By_Akamai-7.patch | 1.11 KB | kunalkursija |
| #5 | 3213827-Exception_Url_Not_Managed_By_Akamai-5.patch | 1.1 KB | kunalkursija |
Comments
Comment #2
kunalkursija commentedComment #3
kunalkursija commentedComment #4
kunalkursija commentedComment #5
kunalkursija commentedAdding a patch. The code is adding the validation to set form error in the case of relative paths starting with a leading
/.Comment #6
kunalkursija commentedComment #7
kunalkursija commentedThe previous patch had an issue with the variable name. This new patch rectifies that.
Comment #8
WidgetsBurritos commentedThis is no longer relevant as as of #3244366: Remove URL validation when invalidating cache. This is presently in the 4.x-dev branch, but will get pushed out as part of a larger release in the next day or so.