Skip to content

fix: Proper error when destination NS of rename OP doesn't exist - #1283

Closed
c-thiel wants to merge 3 commits into
mainfrom
ct/fix-rename-ns-error
Closed

c-thiel wants to merge 3 commits into
mainfrom
ct/fix-rename-ns-error

Conversation

@c-thiel

@c-thiel c-thiel commented Aug 13, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Renaming a table now validates permissions against the destination namespace, ensuring correct authorization.
    • Improved error handling during table rename to return a clearer “Not Found” response when the destination namespace is unavailable or invalid.

@coderabbitai

coderabbitai Bot commented Aug 13, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@c-thiel has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9493ee6 and 53f5ebd.

📒 Files selected for processing (1)
  • crates/lakekeeper/src/catalog/tables.rs (1 hunks)

Walkthrough

The rename_table flow now authorizes against the destination namespace instead of the source. It derives destination_namespace_id from destination.namespace, calls require_namespace_action(CanCreateTable) on it, and maps authorization errors to a not-found-like status via map_err before continuing with existing logic.

Changes

Cohort / File(s) Summary
Rename authorization and error mapping
crates/lakekeeper/src/catalog/tables.rs
In rename_table: compute destination_namespace_id from destination.namespace; perform authZ with CatalogNamespaceAction::CanCreateTable on destination; change error handling to .await.map_err(set_not_found_status_code)?; no public API/signature changes.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant TablesAPI as Tables::rename_table
    participant AuthZ as Authorization
    participant Catalog as Catalog Store

    Client->>TablesAPI: rename_table(source, destination)
    TablesAPI->>TablesAPI: compute destination_namespace_id
    TablesAPI->>AuthZ: require_namespace_action(dest_id, CanCreateTable)
    AuthZ-->>TablesAPI: allow/deny
    alt deny
        TablesAPI->>Client: error (mapped to not-found-like)
    else allow
        TablesAPI->>Catalog: perform rename with existing logic
        Catalog-->>TablesAPI: result
        TablesAPI-->>Client: success
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

I hop through namespaces, nimble and bright,
Checking the destination by moonlit night.
If gates say “no,” I vanish from sight—404-like flight!
But when keys jingle, I rename just right,
Carrots signed off, tables tucked tight. 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ct/fix-rename-ns-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
crates/lakekeeper/src/catalog/tables.rs (2)

918-919: Authorize against destination namespace: correct fix; consider early no-op fast path

Good change to resolve and authorize against the destination namespace. This aligns the check with where the rename will land.

Optional: Short-circuit no-op renames before the destination-namespace lookup and auth to avoid requiring CanCreateTable when source == destination.

Example (outside this hunk, place just before computing destination_namespace_id):

if source == destination {
    return Ok(());
}

925-930: Nit: prefer function pointer in map_err for consistency

Use the function directly to match other call sites and simplify the code.

-            .await
-            .map_err(|e| set_not_found_status_code(e))?;
+            .await
+            .map_err(set_not_found_status_code)?;

This still ensures a not-found-like status when the destination namespace doesn't exist or when authorization should not leak existence.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fc2aba and 9493ee6.

📒 Files selected for processing (1)
  • crates/lakekeeper/src/catalog/tables.rs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
crates/lakekeeper/src/catalog/tables.rs (2)
crates/iceberg-ext/src/catalog/rest/table.rs (1)
  • RenameTableRequest (58-61)
crates/iceberg-ext/src/catalog/mod.rs (2)
  • test_table_ident_serialization (58-66)
  • table (27-27)

@c-thiel
c-thiel force-pushed the ct/fix-rename-ns-error branch from 98e51db to 9493ee6 Compare August 13, 2025 15:37
@c-thiel
c-thiel marked this pull request as ready for review August 26, 2025 17:08
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel

c-thiel commented Sep 19, 2025

Copy link
Copy Markdown
Member Author

Closed in favor of #1346

@c-thiel c-thiel closed this Sep 19, 2025
@c-thiel
c-thiel deleted the ct/fix-rename-ns-error branch October 28, 2025 17:04
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