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

Adds a minimal amount of validation around asset_tags in AssetsController #14421

Conversation

marcusmoore
Copy link
Collaborator

Description

This PR introduces a tiny bit of validation around the asset_tags field in the AssetsController's store method.

We saw a few exceptions pop up in the demo, most likely some someone manually messing with the form, and this gives a little more protection from 500s being thrown from this method.

Type of change

  • Bug fix (ish) (non-breaking change which fixes an issue)

Copy link

what-the-diff bot commented Mar 12, 2024

PR Summary

  • Enforced Array Validation on asset_tags in store()
    • Updated the store() method in the AssetsController.php file with a new validation rule.
    • This rule checks that the asset_tags field is populated and is of array type before an asset is stored. This aims to avoid issues related to missing asset_tags.
    • This validation is only applied during the creation of new assets and won't affect the asset updating process.

@snipe
Copy link
Owner

snipe commented Mar 12, 2024

I think we use that form handler elsewhere (accessories, etc) so I'm not sure we can insist on asset tags here.

@marcusmoore
Copy link
Collaborator Author

marcusmoore commented Mar 12, 2024

I think we use that form handler elsewhere (accessories, etc) so I'm not sure we can insist on asset tags here.

@snipe The Rollbar we were seeing was because $asset_tags was null and "must be of type Countable|array" on this line so it seems like it is actually required right?

for ($a = 1; $a <= count($asset_tags); $a++) {

@snipe
Copy link
Owner

snipe commented Mar 14, 2024

We do in that controller, yes, but your edits are to the ImageUploadRequest, which we use in other (non-asset) places.

@snipe
Copy link
Owner

snipe commented Mar 14, 2024

Nope, never mind - I misread the PR. Sigh.

@marcusmoore
Copy link
Collaborator Author

@snipe friendly ping

@snipe snipe merged commit 7c39f51 into snipe:develop Mar 21, 2024
8 checks passed
@marcusmoore marcusmoore deleted the fixes/add-minimal-validation-around-asset-tags branch March 21, 2024 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants