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

Cannot empty initiate_login_uri with API #731

Closed
7 tasks done
grubolsch opened this issue Sep 28, 2023 · 0 comments · Fixed by #732
Closed
7 tasks done

Cannot empty initiate_login_uri with API #731

grubolsch opened this issue Sep 28, 2023 · 0 comments · Fixed by #732
Assignees
Labels
Scope: Bug Addressing unexpected problems or unintended behavior.

Comments

@grubolsch
Copy link

grubolsch commented Sep 28, 2023

Checklist

SDK Version

8.7

PHP Version

PHP 8.2

Description

When performing a call to update a client with the call https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id, we get an error when me make the field initiate_login_uri empty.

Failed to update Auth0 client(s) {"integration_id":"89826f96-ed00-4110-8fca-5a909cb6442c","exception":"[object] (App\Auth0\Auth0SDKException(code: 400): Auth0 responded with status code 400 instead of 201. Response body: {"statusCode":400,"error":"Bad Request","message":"Payload validation error: 'Expected type string but found type null' on property initiate_login_uri (Initiate login uri, must be https).","errorCode":"invalid_body"} at /var/www/html/app/Auth0/Auth0SDKException.php:17)

Problem is the class vendor/auth0/auth0-php/src/Utility/Toolkit/Filter/StringFilter.php, line 40, it changes all empty string '' values to a NULL, but the API cannot handle this.

We need a change so this field is not set to NULL when empty.

Currently, I have fixed it in the \Auth0\SDK\API\Management\Clients::update class, to add an extra check and restore the empty value.
This code fixes it:

public function update(
        string $id,
        ?array $body = null,
        ?RequestOptions $options = null,
    ): ResponseInterface {
        [$id] = Toolkit::filter([$id])->string()->trim();
        [$body] = Toolkit::filter([$body])->array()->trim();

        if(isset($body['initiate_login_uri']) && $body['initiate_login_uri'] === null) {
            $body['initiate_login_uri'] = '';
        }

        Toolkit::assert([
            [$id, \Auth0\SDK\Exception\ArgumentException::missing('id')],
        ])->isString();

        return $this->getHttpClient()
            ->method('patch')->addPath(['clients', $id])
            ->withBody($body ?? [])
            ->withOptions($options)
            ->call();
    }

How can we reproduce this issue?

Do a call with \Auth0\SDK\API\Management\Clients::update with an empty initiate_login_uri.

@evansims evansims self-assigned this Oct 12, 2023
@evansims evansims added the Scope: Bug Addressing unexpected problems or unintended behavior. label Oct 12, 2023
github-merge-queue bot pushed a commit that referenced this issue Oct 16, 2023
…g for PATCH /api/v2/clients/:id requests. (#732)

### Changes

This PR adds support for `initiate_login_uri` to be supplied as an empty
string to the `/api/v2/clients/:id` endpoint for `PATCH` requests.

### References

Resolves #731 

### Testing

This PR adds a regression testing for the change.

### Contributor Checklist

- [x] I agree to adhere to the [Auth0 General Contribution
Guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md).
- [x] I agree to uphold the [Auth0 Code of
Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Bug Addressing unexpected problems or unintended behavior.
Projects
None yet
2 participants