Automattic / wp-api-console

WordPress (.com and .org) API Console written in React/Redux
GNU General Public License v2.0
70 stars 20 forks source link

Stop crash when param.match( paramDetailsRegex ) fails to match #101

Closed mreishus closed 2 years ago

mreishus commented 2 years ago

Summary

These lines can cause a fatal crash:

https://github.com/Automattic/wp-api-console/blob/014eb1c28c57cb8ca11ed9516f3c17df1a10706d/src/api/core.js#L142-L143

It has something to do with invalid data coming from the backend. It's currently happening with WP.com wpcom/v2 endpoints. Change: Make the code more resilient and ignore the paths that do not match the regex.

To test

{
        "wordpress.com": {
                "client_id": "12345",
                "redirect_uri": "http://localhost:3000"
        }
}

2022-08-16_10-00

dmsnell commented 2 years ago

Some comparisons with #102 are handling of the inputs we don't currently recognize. Notably while we don't crash the app in this PR we still print out garbage to the <LookupContainer> and mess up the parameter inputs, in some cases showing the entire endpoint path/URL as if it's a single parameter, but one which doesn't allow entry.

This PR

Screen Shot 2022-09-10 at 1 21 22 PM Screen Shot 2022-09-10 at 1 21 28 PM Screen Shot 2022-09-10 at 1 21 49 PM Screen Shot 2022-09-10 at 1 21 55 PM

#102

Screen Shot 2022-09-10 at 1 22 18 PM Screen Shot 2022-09-10 at 1 22 24 PM Screen Shot 2022-09-10 at 1 22 31 PM Screen Shot 2022-09-10 at 1 22 36 PM
dmsnell commented 2 years ago

Closing because #102 merged, which should replace this PR.