Return generic error messages in production mode#1357
Conversation
…ider to determine dev mode
Just curious, was this issue resolved now? If yes, does this need to be modified in any way - doesnt have to be part of this PR - but wondering if we need to fix this. Refers to: src/Service/Resolvers/Sql Query Structures/SqlQueryStructure.cs:520 in 4f947e5. [](commit_id = 4f947e5, deletion_comment = False) This was resolved by PR #324. I'll pick up the refactoring changes to remove code paths that don't get executed in a follow-up PR. I've created this issue to track |
src/Service/Resolvers/Sql Query Structures/BaseSqlQueryStructure.cs
Outdated
Show resolved
Hide resolved
src/Service/Resolvers/Sql Query Structures/BaseSqlQueryStructure.cs
Outdated
Show resolved
Hide resolved
src/Service/Resolvers/Sql Query Structures/BaseSqlQueryStructure.cs
Outdated
Show resolved
Hide resolved
src/Service/Resolvers/Sql Query Structures/BaseSqlQueryStructure.cs
Outdated
Show resolved
Hide resolved
…' of https://github.com/Azure/data-api-builder into dev/shyamsundarj/genericize-error-messages-bad-requests
src/Service/Resolvers/Sql Query Structures/BaseSqlQueryStructure.cs
Outdated
Show resolved
Hide resolved
src/Service/Resolvers/Sql Query Structures/BaseSqlQueryStructure.cs
Outdated
Show resolved
Hide resolved
ayush3797
left a comment
There was a problem hiding this comment.
Leaving few comments to address, LGTM otherwise.
Aniruddh25
left a comment
There was a problem hiding this comment.
LGTM. Left few nits. Thanks for refactoring!
In REST Requests: If an invalid column name is used in the requests, it gets caught in Request: Error Message: GraphQL requests: Incase of graphQL requests, hotchocolate catches this and returns the following error message when running in both development and production modes. The code flow in |
Why make this change?
api/Book/id/one.The parameter type for
idshould be an int. In such a case, the error message returned is the following"Parameter \"one\" cannot be resolved as column \"id\" with type \"Int32\".",While this error message is helpful, it reveals more information than necessary. For example, it can be deduced from the error message that the database object backing the entity
Bookis a table and the system type for the columnidisInt32Invalid value provided for field: idwill be returned when running inProductionmode. When running inDevelopmentmode, the detailed error message will be returned.The specified argument value does not match the argument typeis returned irrespective of the host mode being Development or Production.What is this change?
IsDevelopmentMode()is introduced in theISqlMetadataProviderinterface and implementations for this method is provided by the implementing classes.ProductionandDevelopmenthost modes.Additional Refactoring Changes
GetParamAsSystemTypeis introduced which casts the parameter values for tables, views and stored-procedures to the respective column/parameter system types. Separate methods for such casting for tables, views and stored-procedures is refactored to a single common method.How was this tested?
Sample requests
Error Message when running in
Developmentmode:Error Message when running in
Productionmode: