-
-
Notifications
You must be signed in to change notification settings - Fork 332
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
Fix Not Null Violation
to return detailed error response
#1053
Conversation
…olationAPIException` to return a detailed error response that consists of column causing the error
I'll review this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Can we return the column id instead of the column name?
- If I try to add a new record to table that has two NOT NULL columns, I only see the error for the first column. I'd like the response to give me enough info to display error messages within both cells. I think it would be best to handle this case by returning two separate error objects within the top-level array of the JSON response body. But I'm open to other approaches too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some general comments about the format, I haven't looked at the code.
- Why do we need
row_parameters
in the response? Also, why is it calledrow
?, We call itrecord
everywhere else. - We need to be able to return errors for multiple columns, a single
column
key isn't going to work. - We should be using IDs to identify columns to be consistent with the rest of the API. We should also be using PKs to identify records.
I agree with @kgodey on this too. I don't see the use in that param. |
What do you think about my suggestion above?
|
I will rename
This is the actual behaviour of the database, it returns just the first column responsible for the |
Reactions
Thoughts about the larger pictureHere are some situations where the API should respond with error info if an attempt to POST to
For some of these situations (e.g. (a) and (c)), the front end already has sufficient info to perform client-side validation. Others (e.g. (b), (d)), it's not feasible for the front end to perform the validation. @pavish and I briefly discussed using client-side validation to satisfy #775 but I argued that we should opt for server-side validation to reduce complexity. Moving forward
If my train of thought is correct here, then we could rely on client-side validation to solve #775 (although at the cost of increasing complexity on the front end). That would change the priority of #1051 from "blocking important work" to "nice to have someday". |
I think we should remove it. Let's keep errors minimal and only have the information that's needed.
Since the database can't return multiple errors, I think the current format is fine. @silentninja I do think we should rename the -- Generally, I agree with the approach of the frontend valdiating what it can with the information that it is. For one thing, it's the fastest feedback loop for the user.
I do think (b) errors are possible, but it should be unlikely since those columns would have to have been created outside of Mathesar. I think in that case, it's fine for the server validation to be incomplete, we can just show a frontend error for the first cell with an error. |
@seancolsen I'll add some quick thoughts here.
|
This is a great idea, and addresses a concern that's been rattling around in my head about how we'll deal with the case of a row that violates a multi-column unique constraint. For this PR, I think it makes sense to stick with |
Codecov Report
@@ Coverage Diff @@
## master #1053 +/- ##
==========================================
+ Coverage 92.56% 92.70% +0.13%
==========================================
Files 108 108
Lines 3848 3852 +4
==========================================
+ Hits 3562 3571 +9
+ Misses 286 281 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
….exceptions.NotNullViolationAPIException` `details` with column `id`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
I'll leave it to @seancolsen to approve and merge. |
Fixes #1051
Extracts details from Postgres diagnostics and returns a detailed error response that consists of the the column name causing the exception along with other details
Screenshots
Checklist
Update index.md
).master
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin