Skip to content

Conversation

@sanketkedia
Copy link
Contributor

@sanketkedia sanketkedia commented Jan 7, 2026

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Enforced uniqueness by (db name, tenant) tuple
    • Modified logic to fix toctou in create_database
    • Added TryFrom<Row> impls for Database & Tenant objects
    • Made tenant id and database id strongly typed in internal types
  • New functionality
    • ...

Test plan

How are these changes tested?
Added tests

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

None

Observability plan

None

Documentation Changes

None

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor Author

sanketkedia commented Jan 7, 2026

@sanketkedia sanketkedia marked this pull request as ready for review January 7, 2026 03:54
@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Jan 7, 2026

It also consolidates the Spanner tenant and database CRUD flow into a single transactional path with richer validation and error handling, broadens the SysDb error surface, aligns the shared request and response types with chroma_types exports, and refreshes the accompanying tests to cover the new behavior.

Affected Areas

rust/rust-sysdb/src/spanner.rs
rust/rust-sysdb/src/types.rs
rust/types/src/sysdb_errors.rs
rust/types/src/tenant.rs
rust/types/src/api_types.rs
rust/spanner-migrations/migrations/0003-create_databases_unique_index.spanner.sql
rust/sysdb/src/test_sysdb.rs

This summary was automatically generated by @propel-code-bot

.map_err(SysDbError::FailedToReadColumn)?;

// resource_name can be NULL, so we handle the error as None
let resource_name: Option<String> = row.column_by_name("resource_name").ok();
Copy link
Contributor

Choose a reason for hiding this comment

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

Important

[Logic] Using .ok() here swallows all errors, including schema mismatches (e.g., if the resource_name column is missing from the query result).

Since resource_name is nullable, requesting it as Option<String> will correctly handle SQL NULLs by returning Ok(None), while still propagating errors for missing columns or type mismatches.

Suggested change
let resource_name: Option<String> = row.column_by_name("resource_name").ok();
// resource_name can be NULL, so we handle the error as None
let resource_name: Option<String> = row
.column_by_name("resource_name")
.map_err(SysDbError::FailedToReadColumn)?;
Context for Agents
Using `.ok()` here swallows all errors, including schema mismatches (e.g., if the `resource_name` column is missing from the query result). 

Since `resource_name` is nullable, requesting it as `Option<String>` will correctly handle SQL NULLs by returning `Ok(None)`, while still propagating errors for missing columns or type mismatches.

```suggestion
        // resource_name can be NULL, so we handle the error as None
        let resource_name: Option<String> = row
            .column_by_name("resource_name")
            .map_err(SysDbError::FailedToReadColumn)?;
```

File: rust/types/src/tenant.rs
Line: 34

Copy link
Contributor

@tanujnay112 tanujnay112 left a comment

Choose a reason for hiding this comment

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

approved with one comment

@sanketkedia sanketkedia merged commit 6af1747 into main Jan 9, 2026
66 checks passed
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.

3 participants