-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add auth header error handling #250
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alecgeatches
commented
Dec 16, 2024
@@ -27,9 +27,6 @@ abstract public function get_display_name(): string; | |||
|
|||
abstract public function get_endpoint(): string; | |||
|
|||
/** | |||
* @inheritDoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note these @inheritDoc
s were removed due to a failed phpcs check:
$ composer run phpcs
FILE: tests/inc/Mocks/MockDataSource.php
--------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------------------
36 | ERROR | [x] Useless documentation comment with @inheritDoc. (SlevomatCodingStandard.Commenting.UselessInheritDocComment.UselessInheritDocComment)
--------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------------
FILE: inc/ExampleApi/Queries/ExampleApiDataSource.php
--------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------------------
25 | ERROR | [x] Useless documentation comment with @inheritDoc. (SlevomatCodingStandard.Commenting.UselessInheritDocComment.UselessInheritDocComment)
--------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------------
FILE: inc/Config/DataSource/HttpDataSource.php
--------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------------------
30 | ERROR | [x] Useless documentation comment with @inheritDoc. (SlevomatCodingStandard.Commenting.UselessInheritDocComment.UselessInheritDocComment)
--------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------------
maxschmeling
approved these changes
Dec 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow
get_request_headers()
implementors to return aWP_Error
to error-out early. Useful for data sources with complex authentication requirements that may know a request will fail during the auth stage. This will allow for more targeted error messages on authentication failure, and avoid making requests to APIs that will be known to fail.Testing
While using the
trunk
branch, go to Admin -> Settings -> Remote Data Blocks, and create a new "Salesforce B2C" data source.Delete the last character of the Client ID to create an invalid source.
Go to a new post and add the generated Salesforce B2C block.
Open network tools to view the results of requests.
In the Salesforce B2C block, click the "Search for an item" button and type some text into the search bar (e.g.
shirt
).View the network panel, and see the failed request. See a non-specific error message indicating an unauthorized request:
Switch to the
add/auth-header-error-handling
branch, and type into the search bar again.View the network panel, and see the failed request. The request should now contain a authorization-specific error message:

Notes