Skip to content

Conversation

@dimitri-yatsenko
Copy link
Member

Summary

Fix silent failure when table declaration fails due to insufficient permissions.

Problem

When creating a table with cross-schema foreign keys, if the user lacks REFERENCES privilege on the parent schema, the table creation would fail silently:

try:
    self.connection.query(sql)
except AccessError:
    # skip if no create privilege
    return  # <-- Silent failure!

Users only discovered the problem when trying to query the non-existent table later.

Solution

Only suppress AccessError if the table already exists (idempotent declaration). Otherwise, raise with a helpful message:

except AccessError:
    if self.is_declared:
        return  # Table exists, suppress (idempotent)
    raise AccessError(
        f"Cannot declare table {self.full_table_name}. "
        f"Check that you have CREATE privilege on schema `{self.database}` "
        f"and REFERENCES privilege on any referenced parent tables."
    )

Behavior

Scenario Before After
Table exists, no CREATE privilege Silent return ✓ Silent return ✓
Table doesn't exist, no CREATE privilege Silent return ✗ Raises AccessError
Table doesn't exist, no REFERENCES privilege Silent return ✗ Raises AccessError

Closes #1161


🤖 Generated with Claude Code

Previously, AccessError during table declaration was silently swallowed,
causing tables with cross-schema foreign keys to fail without any feedback
when the user lacked REFERENCES privilege.

Now:
- If table already exists: suppress error (idempotent declaration)
- If table doesn't exist: raise AccessError with helpful message about
  CREATE and REFERENCES privileges

Closes #1161

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added bug Indicates an unexpected problem or unintended behavior enhancement Indicates new improvements labels Jan 9, 2026
The test previously expected silent failure at declaration followed by
error at insert time. Now we fail fast at declaration time (better UX).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dimitri-yatsenko dimitri-yatsenko merged commit 8732f87 into pre/v2.0 Jan 9, 2026
8 checks passed
@dimitri-yatsenko dimitri-yatsenko deleted the fix/1161-silent-declare-failure branch January 9, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Indicates an unexpected problem or unintended behavior enhancement Indicates new improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants