Skip to content

rgw/s3vectors: prevent underscores in metadata keys - #71084

Closed
yuvalif wants to merge 2 commits into
ceph:wip-s3vectorfrom
yuvalif:no-underscore-in-metadata
Closed

yuvalif wants to merge 2 commits into
ceph:wip-s3vectorfrom
yuvalif:no-underscore-in-metadata

Conversation

@yuvalif

@yuvalif yuvalif commented Aug 16, 2026

Copy link
Copy Markdown
Contributor
  • make it consisitent for all metadata fields
  • enfore the key name length

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Comment thread src/rgw/rgw_s3vector.cc Outdated
if (name == key_field || name == data_field || name == metadata_field || name.starts_with('_')) {
// internal columns are the ones starting with an underscore, and a
// metadata key name may never start with one
if (name.starts_with('_')) {

@galsalomon66 galsalomon66 Aug 23, 2026 •

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.

the validate_metadata_key_name uses the same "_" prefix rule.
it's better to use a shared function for the case we change _ to $ (for one example)

Comment thread src/rgw/rgw_s3vector.h Outdated
// validate the name of a metadata key. returns the reason the name is invalid,
// or std::nullopt if it is valid. the returned message has no subject, so that
// the caller could prefix it with the name as it appears in its own context
inline std::optional<std::string> validate_metadata_key_name(const std::string& name) {

@galsalomon66 galsalomon66 Aug 23, 2026 •

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.

it should allow only [a-zA-Z0-9] unless it is certain that lance FFI are blocking key-names which are not comply to that.
the column name should not contain double-quote(") , it may disrupt the datafusion expression.

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.

user may create key-names as $eq, $and, $or and other JSON query operators, it seems its not blocked upon create-index,put-vectors.
if that is the case, it will impact the query operation.

the validate_metadata_key_name should block meta-char in key-names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i can think of several directions with a solution for the field names:

  • restrict column names to alphanumeric (maybe also underscores - mid name)
    • pros: simple to document and explain
    • cons: will make us much more restrictive than AWS
  • distinguish filterable from regular column names
    • for regular column names - probably no restrictions (also long as the JSON blob is valid). maybe even remove the exiting restrictions on starting with underscore
    • maybe just prevent from filter ops ($rw, $or, $end), or to start with "$" in general to support any future ops
    • for filterable column names, use the existing restrictions, and in addition, let lancedb reject whatever it does not like
    • pros: would be AWS complient, since filterableMetadataFileds is an extension anyway
    • cons: hard dodocument, especially, since we are not 100% what are (and going to be the lancedb restrictions)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

regarding the first option. looks like AWS API accepts all types of key names, including leadign and trailing spaces, dots, reserved filter operators etc.
e.g.:

[
  {
    "key": "my-vector-6",
    "metadata": {
      "my'key": "example"
    }
  },
  {
    "key": "my-vector-2",
    "metadata": {
      " mykey ": "example"
    }
  },
  {
    "key": "my-vector-1",
    "metadata": {
      "my key": "example"
    }
  },
  {
    "key": "my-vector-10",
    "metadata": {
      "`my-key`": "example"
    }
  },
  {
    "key": "my-vector-7",
    "metadata": {
      "המפתח שלי": "example"
    }
  },
  {
    "key": "my-vector-9",
    "metadata": {
      "my.key": "example"
    }
  },
  {
    "key": "my-vector-8",
    "metadata": {
      "$eq": "example"
    }
  },
  {
    "key": "my-vector-3",
    "metadata": {
      "'mykey'": "example"
    }
  },
  {
    "key": "my-vector-11",
    "metadata": {
      "my'key": "example"
    }
 },
  {
    "key": "my-vector-4",
    "metadata": {
      "\"mykey\"": "example"
    }
  },
  {
    "key": "my-vector-5",
    "metadata": {
      "my\"key": "example"
    }
  }
]

which makes filter like that valid:

filter={"$or": [{"$or": {"$eq": "example"}}, {"my.key": {"$eq": "example"}}]}

here the first "$or" is a filter operator and the 2nd "$or" is a key name.

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.

we need to verify whether our implementation can handle all of these combinations (as AWS)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

is this missing from the tests?

@yuvalif
yuvalif requested a review from a team as a code owner August 27, 2026 08:15
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

without raw_utf8 every byte of a multi-byte character was escaped on its own
as a separate code point, so: "café" came back as "café"

Signed-off-by: Yuval Lifshitz <[email protected]>
Assisted-by: claude-code:claude-fable-5.1
@yuvalif
yuvalif force-pushed the no-underscore-in-metadata branch from 45c63d2 to c0612a8 Compare September 7, 2026 13:45
* enforce the key name length only for declared keys
* enforce backtics only for declared keys
* make sure that utf8 keys are supported
* make sure that keys are case sensitive
* make sure that quotes and single quotes are supported

Signed-off-by: Yuval Lifshitz <[email protected]>
Assisted-by: claude-code:claude-opus-5
@yuvalif

yuvalif commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

cherry picked to wip-s3vector

@yuvalif yuvalif closed this Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants