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

Fix a problem when a composite identifier is missing #1182

Merged

Conversation

raoulclais
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

This PR fixes a bug when a resource is requested with a wrong composite identifier, like 'ida=1;' instead of 'ida=1;idb=2'.

@soyuka
Copy link
Member

soyuka commented Jun 16, 2017

Failures are not related, I'll fix those in a new PR.

try {
$identifiers = $this->normalizeIdentifiers($id, $manager, $resourceClass);
} catch (PropertyNotFoundException $e) {
throw new BadRequestHttpException($e->getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception should be InvalidArgumentException.

@soyuka
Copy link
Member

soyuka commented Jun 16, 2017

Thanks for the patch @raoulclais ! May you rebase on 2.0 instead of merging?

For example:

# first reset the merge
git fetch origin # assuming origin remote points to api-platform/core not your fork
git rebase origin/2.0
git push -f upstream hotfix/missing-composite-identifier # assuming upstream remote points to your fork

You may have to reset to skip the merge commit from above.

Another solution is to submit your patch without merging and we will take care of rebasing :). Thanks!

@raoulclais raoulclais force-pushed the hotfix/missing-composite-identifier branch 2 times, most recently from 9fa9efa to b1c81fe Compare June 16, 2017 16:40
@Simperfit Simperfit requested a review from dunglas June 16, 2017 19:42
@raoulclais raoulclais force-pushed the hotfix/missing-composite-identifier branch from 8c269bc to 985710e Compare June 19, 2017 15:51
@Simperfit Simperfit merged commit 4e1b109 into api-platform:2.0 Jun 19, 2017
@Simperfit
Copy link
Contributor

Thanks @raoulclais

Scenario: Get the first composite relation with a missing identifier
Given there are Composite identifier objects
When I send a "GET" request to "/composite_relations/compositeLabel=1;"
Then the response status code should be 400
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be 404, not 400...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resource could never be found because the composite is invalid, why 404 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's "not found"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server did not even search it in the DB ^^

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10.4.5 404 Not Found
The server has not found anything matching the Request-URI.

This is by definition what happened here no? Though, one could argue that the url is malformed (hence 400).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is totally my point ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so @teohhanhui @soyuka what do we do ? :o

@raoulclais raoulclais deleted the hotfix/missing-composite-identifier branch December 26, 2017 13:31
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
…omposite-identifier

Fix a problem when a composite identifier is missing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants