Improve GraphQL error handling by mapping all DataApiBuilderException types to appropriate HTTP status codes
What's changed
This PR enhances the DabGraphQLResultSerializer class to properly map all types of DataApiBuilderException.SubStatusCodes to their appropriate HTTP status codes in GraphQL responses.
Previously, the serializer only handled one specific error type (DatabaseInputError) and would return BadRequest (400) status code for it, while defaulting to server error (500) for all other exceptions.
Now, the serializer has been updated to:
- Map authentication errors to 401 Unauthorized
- Map authorization errors to 403 Forbidden
- Map entity/item not found errors to 404 NotFound
- Map input validation errors to 400 BadRequest
- Map unsupported features to 501 NotImplemented
- Map conflict errors to 409 Conflict
- Map server-side errors to 500 InternalServerError
This implementation ensures that GraphQL responses have the appropriate HTTP status codes that match the nature of the error, which improves API consistency and allows clients to better handle different error types.
The class documentation has also been updated to clearly explain the purpose and behavior of the serializer.
Fixes #2691.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
cdn.fwupd.orgcrl3.digicert.com
- Triggering command:
dotnet build src/Azure.DataApiBuilder.sln(dns block)crl4.digicert.com
- Triggering command:
dotnet build src/Azure.DataApiBuilder.sln(dns block)dc.services.visualstudio.comocsp.digicert.com
- Triggering command:
dotnet build src/Azure.DataApiBuilder.sln(dns block)s.symcb.com
- Triggering command:
dotnet build src/Azure.DataApiBuilder.sln(dns block)s.symcd.com
- Triggering command:
dotnet build src/Azure.DataApiBuilder.sln(dns block)testts-crl.ws.symantec.com
- Triggering command:
dotnet build src/Azure.DataApiBuilder.sln(dns block)ts-ocsp.ws.symantec.com
- Triggering command:
dotnet build src/Azure.DataApiBuilder.sln(dns block)www.microsoft.com
- Triggering command:
dotnet build src/Azure.DataApiBuilder.sln(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
/azp run
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.