Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel][Debug] Get exception content according to request format#30851

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@yceruto
Copy link
Member

@ycerutoyceruto commentedApr 3, 2019
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#25905
LicenseMIT

Mainly for API-based apps that don't require TwigBundle to get the correct exception response according to the request format (aka_format attribute).

exception_response

Let me know if this classify as a bugfix for 4.2, but IMHO this was never supported without TwigBundle, hencemaster branch.

thrownewNotFoundHttpException('Resource not found.',null,0, ['Content-Type' =>'application/problem+json']);

fancyweb, dmaicher, bigfoot90, and naroga reacted with hooray emojifancyweb and naroga reacted with heart emoji
@fabpot
Copy link
Member

You're right, this is for master.

@ycerutoycerutoforce-pushed theexception_response_format branch from3d66ef3 toaa6bc3dCompareApril 3, 2019 14:47
@nicolas-grekas
Copy link
Member

Do we follow any RFC regarding the formatting of the json/xml/etc payloads?
If not, what about doing it? See#30559

@nicolas-grekasnicolas-grekas added this to thenext milestoneApr 3, 2019
@yceruto
Copy link
MemberAuthor

yceruto commentedApr 3, 2019
edited
Loading

Do we follow any RFC regarding the formatting of the json/xml/etc payloads?

Not really, I just copied the content format from TwigBundle exceptions.

If not, what about doing it? See#30559

Good idea! I'll check the RFC for each response format.

Later, I guess we should update the TwigBundle errors/exceptions as well.

@yceruto
Copy link
MemberAuthor

Status: Needs Work

@yceruto
Copy link
MemberAuthor

Status: Needs Review

@ycerutoycerutoforce-pushed theexception_response_format branch from94167b0 to259fa20CompareApril 3, 2019 19:22
@yceruto
Copy link
MemberAuthor

This is ready so far, because we don't have more info from HttpException, but if we wanted to complete the spec details...

https://tools.ietf.org/html/rfc7807#section-3
The ability to convey problem-specific extensions allows more than one problem to be conveyed.

... we might need a meta argument containing standard (e.g.type,instance) and/or non-standard (e.g.balance,invalid-params, etc) meta-information about the error.

Ideally something like this:

thrownewProblemDetailsHttpException(400,'Your request parameters didn't validate.', null, ['Content-Type' =>'application/problem+json'],0, ['type' =>'https://example.net/validation-error','invalid-params' => [         ['name' =>'age','reason' =>'must be a positive integer'        ],        ['name' =>'color','reason' =>'must be green, red or blue'        ],    ],]);

then, the last argument (named e.g. meta) could be handled byFlattenException and merge it into the final formatted content. WDYT?

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment
edited
Loading

Choose a reason for hiding this comment

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

Nice, thanks.
About your last comment, I wouldn't go further for a generic Debug component - for now at least.

yceruto reacted with thumbs up emoji
Copy link
Contributor

@dmaicherdmaicher left a comment

Choose a reason for hiding this comment

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

👍

}elseif (class_exists(Response::class) &&isset(Response::$statusTexts[$statusCode])) {
$title = Response::$statusTexts[$statusCode];
}else {
$title ='Internal Server Error';
Copy link
Contributor

Choose a reason for hiding this comment

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

so a 403 error withoutsymfony/http-foundation installed would lead to this title/message? Might be a bit confusing 😄

$exception = FlattenException::create($exception);
}

if (404 ===$statusCode =$exception->getStatusCode()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this blocks seems repeated for all content-types? maybe move it to a private method?

@fabpot
Copy link
Member

@yceruto Thank you for working on this topic, which we should tackle. But I don't think this is the right approach. Let's talk about this this week-end during the Hackaton.

@yceruto
Copy link
MemberAuthor

@fabpot then I guess should I close here, right?

@fabpot
Copy link
Member

No, we should talk first

@yceruto
Copy link
MemberAuthor

As discussed, this code should be moved to a new component (maybeErrorException) that could be used in both "prod" (where a Debug component doesn't make sense) and dev as hard dep of theHttpKernel component.

Later, theExceptionListener can use it and also the Debug req can be moved torequire-dev section in the future.

@yceruto
Copy link
MemberAuthor

See#31065

@ycerutoyceruto deleted the exception_response_format branchApril 16, 2019 14:58
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+1 more reviewer

@dmaicherdmaicherdmaicher left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

5 participants

@yceruto@fabpot@nicolas-grekas@dmaicher@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp