Skip to content

Conversation

@Spomky
Copy link
Contributor

@Spomky Spomky commented Jul 11, 2025

Q A
Bug fix? no
New feature? no
Docs? no
Issues none
License MIT

Hi,

I am not sure w need the webmozart/assert dependency for just one verification.
Let me squash this PR before any action (I am not with my usual setup at the moment).

Regards.

@Spomky Spomky requested review from Nyholm and chr-hertel as code owners July 11, 2025 12:59
@Spomky Spomky marked this pull request as draft July 11, 2025 13:02
Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you. I agree

public Metadata $metadata = new Metadata(),
) {
Assert::stringNotEmpty(trim($this->content));
'' !== trim($this->content) || throw new \InvalidArgumentException('The content shall not be an empty string');
Copy link
Member

Choose a reason for hiding this comment

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

Let's be more explicit and do

if ('' === trim($this->content)) {
  throw new \InvalidArgumentException('The content shall not be an empty string');
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Nyholm,

You're absolutely right the if notation is more explicit. However in this case I opted for the shorter expression to maintain consistency across classes that perform many inline validations, such as the With class.

My goal was to keep the constructor concise and uniform, even if slightly less explicit.
That said, if you feel strongly about it, I will witch to the if version for clarity.

@chr-hertel
Copy link
Member

yes, agree as well, but for the Platform component you'd need to replace more code - or keep it for now and only take action on store

@Spomky
Copy link
Contributor Author

Spomky commented Jul 11, 2025

Yes indeed. I will continue this PR when I get back home on Thursday.

@chr-hertel chr-hertel added Store Issues & PRs about the AI Store component Status: Needs Work labels Jul 12, 2025
@Spomky Spomky force-pushed the deps/no-assert branch 4 times, most recently from c774eb2 to 750d75c Compare July 15, 2025 07:33
@Spomky Spomky marked this pull request as ready for review July 15, 2025 07:34
@Spomky Spomky requested a review from OskarStark as a code owner July 15, 2025 07:34
Comment on lines 36 to 40
!str_starts_with($this->baseUrl, 'http://') || throw new \InvalidArgumentException('The base URL must not contain the protocol.');
!str_starts_with($this->baseUrl, 'https://') || throw new \InvalidArgumentException('The base URL must not contain the protocol.');
'' !== $deployment || throw new \InvalidArgumentException('The deployment must not be empty.');
'' !== $apiVersion || throw new \InvalidArgumentException('The API version must not be empty.');
'' !== $apiKey || throw new \InvalidArgumentException('The API key must not be empty.');
Copy link
Member

Choose a reason for hiding this comment

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

Let's us the component specific exception here please: Symfony\AI\Platform\Exception\InvalidArgumentException

Copy link
Member

Choose a reason for hiding this comment

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

same for the other places as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed I had missed this class.
I have updated it wherever necessary.

@OskarStark OskarStark changed the title [AI Store] Remove the Assert library [AI Store] Remove webmozart/assert library Jul 15, 2025
@OskarStark
Copy link
Contributor

I will prepare a PR to add unit tests for the code parts using the lib. So we can merge my PR first, then rebase and check the CI 👍

@OskarStark
Copy link
Contributor

Here you go:

@chr-hertel
Copy link
Member

Merged Oskar's tests, rebase please :)

@Spomky
Copy link
Contributor Author

Spomky commented Jul 15, 2025

Thanks. Rebased, squashed and tests are ok.
I noted there are InvalidArgumentException classes in ai-platform, agent and store.
As agent and store depend on ai-platform, do you think interesting to remove redundant classes? (not here, but another PR)

@chr-hertel
Copy link
Member

From a design point of view my understanding was that we want exceptions clustered per package - rather a best practice than tho.
how does symfony/symfony handle this? throwing exceptions of a dependency feels a bit odd to me - it's an extra dependency and not explicitly design for that 🤔

@OskarStark
Copy link
Contributor

Yes per package, imagine you are just using one package, the exception will not be available.

@chr-hertel
Copy link
Member

Thank you @Spomky.

@chr-hertel chr-hertel merged commit 1f91152 into symfony:main Jul 15, 2025
12 checks passed
@Spomky Spomky deleted the deps/no-assert branch July 15, 2025 12:25
@Spomky
Copy link
Contributor Author

Spomky commented Jul 15, 2025

You are welcome.
Noted for the design. Makes sense.

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

Labels

Store Issues & PRs about the AI Store component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants