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

Poor error-handling of invalid default values makes it hard for users to add new records #4036

Open
seancolsen opened this issue Nov 25, 2024 · 0 comments
Labels
needs: requirements The problem is clear and worth solving, but we're not yet sure of the best solution restricted: maintainers Only maintainers can resolve this issue type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL work: frontend Related to frontend code in the mathesar_ui directory
Milestone

Comments

@seancolsen
Copy link
Contributor

seancolsen commented Nov 25, 2024

Interestingly, it's possible for a column's default value to be set to a value which is not actually valid for the column. Consider the following examples:

  • A default value set for an FK column and the the referenced record subsequently deleted
  • A default value of "blah blah" set for a Mathesar URI or Email column
  • A text value set on a column with a unique constraint

If these states arise, it will be impossible for users to add new records to the table. The error looks like this:

image

Reading that error, it's pretty hard to tell why I couldn't add a new Authors record — and how to fix it!

These default value states are possible in PostgreSQL but are pretty weird. While I wouldn't expect to see states like this in a typical production DB, they are all possible states to produce through Mathesar. And the reason I'm reporting this issue at all is that Amanda and I bumped into a state like this during her product onboarding. We were using the internal site and someone else had apparently set the Authors.Website default value to "Website to be determined" — an invalid URI. I didn't realize this until I spent some time troubleshooting it after our call.

One way to approach this problem would be to validate default values when they are set. But I don't think that would actually get us very far towards addressing the problem here. Various forms of validation can be added after the default value is set, subsequently rendering it invalid.

Ideally we'd have some more graceful error handling, alerting the user to the root cause of the error and instructing them on how to fix it.

@seancolsen seancolsen added needs: requirements The problem is clear and worth solving, but we're not yet sure of the best solution restricted: maintainers Only maintainers can resolve this issue type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL work: frontend Related to frontend code in the mathesar_ui directory labels Nov 25, 2024
@seancolsen seancolsen added this to the Backlog milestone Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: requirements The problem is clear and worth solving, but we're not yet sure of the best solution restricted: maintainers Only maintainers can resolve this issue type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL work: frontend Related to frontend code in the mathesar_ui directory
Projects
None yet
Development

No branches or pull requests

1 participant