Skip to content

Conversation

@tanujnay112
Copy link
Contributor

@tanujnay112 tanujnay112 commented Dec 6, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Errors fixed:
      • Param validation
      • Output collection already exists error looks nicer now
      • Function already exists error looks cleaner
      • Invalid function to be attached error added
      • Collection already has an attached function
  • New functionality
    • ...

Test plan

How are these changes tested?

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

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the _docs section?_

@tanujnay112 tanujnay112 marked this pull request as ready for review December 6, 2025 00:44
@github-actions
Copy link

github-actions bot commented Dec 6, 2025

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

tanujnay112 commented Dec 6, 2025

@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Dec 6, 2025

Improve attach_function validation and error surfacing across stack

This PR tightens attach_function validation in the Go coordinator, updates Rust clients to surface precise gRPC errors, and expands distributed integration tests to cover newly handled cases. It introduces deterministic function-ID to name mapping for built-in operators, enforces empty params, and ensures output-collection conflicts and mismatched attachments return actionable messages end-to-end.

Key Changes

• Refactored validateAttachedFunctionMatchesRequest in go/pkg/sysdb/coordinator/task.go to return a boolean/matched sentinel, short-circuit mismatches without DB lookups, enforce empty params, and surface rich AlreadyExists / InvalidArgument errors via grpcutils.
• Added built-in function ID→name map and GetFunctionNameByID helper in go/pkg/sysdb/metastore/db/dbmodel/constants.go, with downstream usage in coordinator and Rust conversions to avoid DB fetches for known functions.
• Expanded Rust sysdb client (rust/sysdb/src/sysdb.rs) and frontend (rust/frontend/src/impls/service_based_frontend.rs) error enums to propagate detailed gRPC status messages (already-exists, failed-precondition, invalid-argument, output-collection-exists) and map finish-create conflicts cleanly.
• Augmented integration coverage in chromadb/test/distributed/test_task_api.py for conflicting attachments, invalid params, and pre-existing output collections to assert new error strings.
• Adjusted gRPC service (go/pkg/sysdb/grpc/task_service.go) to translate coordinator errors into explicit NotFound / AlreadyExists responses and preserve existing gRPC statuses from downstream calls.

Affected Areas

• go/pkg/sysdb/coordinator/task.go
• go/pkg/sysdb/grpc/task_service.go
• go/pkg/sysdb/metastore/db/dbmodel/constants.go
• rust/sysdb/src/sysdb.rs
• rust/frontend/src/impls/service_based_frontend.rs
• chromadb/test/distributed/test_task_api.py
• rust/types/src/api_types.rs
• rust/types/src/flush.rs

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

@blacksmith-sh

This comment has been minimized.

AlreadyExists,
#[error("{0}")]
CollectionAlreadyHasFunction(String),
#[error("{0}")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to see if this is ok

@tanujnay112 tanujnay112 changed the title [ENH]: Make error messages in attach_function better [ENH]: Make error messages in attach_function clearer Dec 8, 2025
@blacksmith-sh

This comment has been minimized.

@tanujnay112 tanujnay112 force-pushed the fix_errors branch 2 times, most recently from dfd5bd9 to 2bfc4a0 Compare December 8, 2025 10:48
Comment on lines 1957 to 1969
chroma_types::FinishCreateAttachedFunctionError::OutputCollectionExists => {
chroma_types::AttachFunctionError::OutputCollectionExists(
output_collection.clone(),
)
}
chroma_types::FinishCreateAttachedFunctionError::AttachedFunctionNotFound => {
chroma_types::AttachFunctionError::Internal(Box::new(e))
}
chroma_types::FinishCreateAttachedFunctionError::FailedToFinishCreateAttachedFunction(
status,
) => chroma_types::AttachFunctionError::Internal(Box::new(
chroma_error::TonicError(status),
)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason AttachFunctionError doesn't just have a Finish variant that takes one of these as its arg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed and cleaned up

Comment on lines +503 to +505
// Note: validateAttachedFunctionMatchesRequest uses dbmodel.GetFunctionNameByID (static lookup)
// which returns "record_counter" for FunctionRecordCounter - different from requestedOperatorName
// Validation returns (false, nil) early, so DatabaseDb.GetDatabases is NOT called
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it different from recordOperatorName? What's the implication? Tell me that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AI wrote this but requestedOperatorName is a variable above. This test seeks to make sure that if you try to attach another function to a collection that already has a different function attached, you will try to see if the requested function attachment matches the previously attached function and fail. This part of the test makes sure that it doesn't make any further database calls during this check/

@blacksmith-sh

This comment has been minimized.

Copy link
Contributor

@rescrv rescrv left a comment

Choose a reason for hiding this comment

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

I'd clean up the logging sprintf so it looks good when it errors.

pub enum AttachFunctionError {
#[error("Attached function already exists")]
AlreadyExists,
#[error("{0}")]
Copy link
Contributor

Choose a reason for hiding this comment

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

This will sprintf the string with no per-variant string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@tanujnay112 tanujnay112 merged commit 54d8c8c into main Dec 9, 2025
64 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