Repository navigation
Do not report validation errors as rate limits - #87
Merged
Merged
Conversation
When receiving a validation error (as in KnpLabs#86) there is no `X-RateLimit-Remaining` header included with the response. That is quite confusing. Here `$remaining` when cast to a string is set to "" (empty string). This does not strictly equal null and thus a `ApiLimitExceedException` is thrown. This change fixes this behavior. cURL requests/responses: ``` # Request: POST /repos/kasperg/release-asset-test/releases/92217/assets?name=test2.txt HTTP/1.1 Host: uploads.github.com 0: Accept: application/vnd.github.v3+json 1: User-Agent: php-github-api (http://github.com/KnpLabs/php-github-api) Content-Type: text/plain, text/plain User-Agent: Guzzle/3.7.4 curl/7.30.0 PHP/5.3.27 Authorization: Basic a2FzcGVyZzpwaW5rbW9ucw== Content-Length: 14 {"body":"122"} # Response: HTTP/1.1 422 status code 422 Cache-Control: no-cache Content-Length: 214 Content-Type: application/json; charset=utf-8 X-Content-Type-Options: nosniff X-Github-Media-Type: github.beta; format=json X-Github-Request-Id: a6633df9-4dff-11e3-800a-0be28f962e12 Date: Fri, 15 Nov 2013 14:10:15 GMT {"message":"Validation Failed","request_id":"a6633df9-4dff-11e3-800a-0be28f962e12","documentation_url":"http://developer.github.com/v3","errors":[{"resource":"ReleaseAsset","code":"already_exists","field":"name"}]} ```
cursedcoder
added a commit
that referenced
this pull request
Nov 15, 2013
Do not report validation errors as rate limits
Contributor
|
Thanks! Merged |
This file contains hidden or 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
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.
When receiving a validation error (as in #86) there is no
X-RateLimit-Remainingheader included with the response. That is quite confusing.Here
$remainingwhen cast to a string is set to "" (empty string). This does not strictly equalnulland thus aApiLimitExceedExceptionis thrown.This change fixes this behavior.
cURL requests/responses: