Skip to content

Conversation

@mosesacknals139
Copy link

Summary

This PR adds validation to prevent invalid column IDs from reaching create_constraint() which previously caused a 500 Internal Server Error.
Now, when the user sends an invalid column id (ex: column does not exist in table), the RPC returns a 400 Bad Request with IntegrityAPIException, instead of crashing.

What was changed

Valid column IDs are collected using get_column_info_for_table(table_oid)

Before calling create_constraint(), each column is checked

If an invalid ID is found, IntegrityAPIException is raised and request stops early

Prevents database failure and the bug mentioned in reviewer feedback

Files Modified

✔ mathesar/rpc/constraints.py

✔ mathesar/api/exceptions/database_exceptions/base_exceptions.py

(Attach your screenshot here)

Checklist

Changes tested locally

Only required files modified

No breaking behavior for valid constraints

Fix prevents 500 error and returns meaningful response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant