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

feat(assemble): Improve error messages for assemble endpoint #88905

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

iambriccardo
Copy link
Member

@iambriccardo iambriccardo commented Apr 7, 2025

This PR improves the error messages for the assemble endpoint.

Closes: #88068

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 7, 2025
return Response({"error": str(e).splitlines()[0]}, status=400)
# Get the field from the path if available
field = None
if e.path:
Copy link
Member Author

Choose a reason for hiding this comment

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

This field contains a queue of the fields inside the schema that are matched.

@iambriccardo iambriccardo requested a review from Copilot April 7, 2025 13:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

path = list(e.path)
field = path.pop(0) if path else None

return Response({"error": error_messages.get(field, e.message)}, status=400)
Copy link
Preview

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

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

If 'field' is not a string (for example, if it's an integer from an array index), the lookup in error_messages may fail unexpectedly. Consider explicitly casting 'field' to a string for consistency: error_messages.get(str(field), e.message).

Suggested change
return Response({"error": error_messages.get(field, e.message)}, status=400)
return Response({"error": error_messages.get(str(field), e.message)}, status=400)

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message for invalid version
1 participant