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

[Uid] Add value toInvalidArgumentException#60323

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

Conversation

rela589n
Copy link
Contributor

@rela589nrela589n commentedMay 2, 2025
edited by OskarStark
Loading

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?no
Followssymfony/symfony-docs#20900 ,
[Uid] Add component-specific exception classes ,
[HttpFoundation] Add UriSigner::verify() that throws named exceptions
LicenseMIT

This PR adds value to Uid-specific InvalidArgumentException.

Thus, anybody who wants to catch the exception, being outside of the scope of the client code, will be able to do so, having the knowledge of what particularly has gone wrong.

@rela589nrela589nforce-pushed thefeat-invalid-argument-exception-value branch from3982cdf tof4a50b9CompareMay 2, 2025 07:12
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedMay 4, 2025
edited
Loading

I challenged adding these properties in the PRs linked in the above description.
I'm still skeptical about adding them as I don't think reporting back the failing values as structured data belongs to the "exceptions" domain. This feels more like signaling, and clearly that's not what exceptions are for, even if they can be used for this, but in a hacky way IMHO.

https://externals.io/message/127188 andhttps://externals.io/message/127206 might give some food for thoughts on the topic.

@rela589n
Copy link
ContributorAuthor

If you want to hear my opinion on these, I think it's reinventing the wheel.

There's already established mechanism that developers use for "your input is invalid in a totally predictable way" kind of errors - exceptions. Forasmuch as exceptions are slow, it would make sense to think up the way to make them faster, not to reinvent them.

Even though exceptions are somewhat slow, they are not so stupendously slow as database queries, file reads and writes, or any other kind of IO, where PHP just waits for the IO to complete and can nothing in the meantime.

I believe that if Edmond doesn't lose faith, it would be solved in the next iterations of True Async.

@rela589n
Copy link
ContributorAuthor

Also, don't you think that having the original value of uid that has failed validation in logs is useful?

@@ -41,7 +41,7 @@ abstract public static function fromString(string $uid): static;
public static function fromBinary(string $uid): static
{
if (16 !== \strlen($uid)) {
throw new InvalidArgumentException('Invalid binary uid provided.');
throw new InvalidArgumentException($uid,'Invalid binary uid provided.');
Copy link
Member

Choose a reason for hiding this comment

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

I quickly scanned our code on how we deal in other places with invalid arguments. Having a dedicated argument is something we don't have anywhere else, but we could embed the invalid value in the exception message. That's something we do quite frequently.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Having a dedicated argument is something we don't have anywhere else

That's a lie.

A lot of exceptions allow passing invalid argument, and expose it.

For example, few exceptions fromDependencyInjection:

  • DependencyInjection\Exception\AutowiringFailedException exposes service id
  • DependencyInjection\Exception\ParameterCircularReferenceException exposes array of parameters
  • DependencyInjection\Exception\ParameterNotFoundException exposes key, sourceId, sourceKey, alternatives, etc
  • DependencyInjection\Exception\ServiceCircularReferenceException exposes service id
  • DependencyInjection\Exception\ServiceNotFoundException exposes service id, and other

And there are at least 40 other distinct exceptions that follow it.

@xabbuhxabbuh added the ❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze" labelMay 5, 2025
@OskarStarkOskarStark changed the title[Uid] add value to InvalidArgumentException[Uid] Add value toInvalidArgumentExceptionMay 5, 2025
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedMay 9, 2025
edited
Loading

Also, don't you think that having the original value of uid that has failed validation in logs is useful?

The failing value is / could be found in the error message, just not in a structured way.

Let me 👎 here sorry, I already explained why and I don't see much support from others either so let's move on.

@chalasr
Copy link
Member

I don't see much need for accessing the problematic uid either, thanks for proposing.

@chalasrchalasr closed thisMay 9, 2025
@rela589n
Copy link
ContributorAuthor

This is absolutely useful for the case when we need to retrieve the value from logs. Don't expect people to parse exception message to get the list of all the values that failed processing.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@xabbuhxabbuhxabbuh left review comments

Assignees
No one assigned
Labels
Feature❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze"Status: Needs ReviewUid
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

5 participants
@rela589n@nicolas-grekas@chalasr@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp