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

Make sure we're getting an object instead of a collection on Asset API for model_id #14055

Merged

Conversation

snipe
Copy link
Owner

@snipe snipe commented Dec 19, 2023

We were being haunted by a bug that was returning Property [fieldset] does not exist on this collection instance via API for some users. In introspecting their payloads, they were sending an array instead of an int as the model ID. While we validate this at the asset level, when we're searching for the model ID., laravel can sometimes "helpfully" return a collection instead of a specific object. This is all well and good, but in this case we want only one model_id's results.

Signed-off-by: snipe <snipe@snipe.net>
Copy link

what-the-diff bot commented Dec 19, 2023

PR Summary

  • Refinement to Model Retrieval in Asset Storage
    The way we obtain the 'model' in the function for storing Assets has been upgraded. Initially, the 'find' function was used to get the 'model_id' from the request. But now, it's been changed to a more targeted approach. We're now using a 'where' clause that precisely gets the 'model_id' equal to the one in the request, and only the first match is returned. This enhances the efficiency and pinpoint accuracy when retrieving the 'model' information.

Signed-off-by: snipe <snipe@snipe.net>
@snipe snipe changed the title Get an object instead of a collection Make sure we're getting an object instead of a collection on Asset API for model_id Dec 19, 2023
@snipe snipe merged commit fe51d0e into develop Dec 19, 2023
7 checks passed
@snipe snipe deleted the bug/disallow_arrays_for_model_id_in_api_hardware_update branch December 19, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant