Skip to content

feat: add a generic metadata: field to all resources - #9872

Open
nishantmonu51 wants to merge 5 commits into
mainfrom
nishant/resource-metadata
Open

feat: add a generic metadata: field to all resources#9872
nishantmonu51 wants to merge 5 commits into
mainfrom
nishant/resource-metadata

Conversation

@nishantmonu51

Copy link
Copy Markdown
Collaborator

Adds a top-level metadata: map to every resource YAML file, parsed generically in commonYAML and stored on ResourceMeta.metadata (proto field 20). This mirrors the generic tags: field, and gives teams a supported way to attach their own metadata (owner, tier, classification, ticket link) to a resource and read it back out over the API.

  • Strict validation is unchanged. Unknown fields still error; there is no prefix exemption.
  • Values are strings. Non-string scalars are coerced, so tier: 1 becomes "1" and pii: false becomes "false", and a null value becomes "". A nested map or list is a parse error naming the offending key.
  • Exposed on meta in GetResource / ListResources / WatchResources. Nothing in Rill interprets it.
  • Also settable from SQL annotations (-- @metadata.owner: alice), so .sql-only models can carry it too.
  • An auto-generated inline explore inherits its metrics view's metadata, matching how tags behaves.
  • dev: / prod: overrides work. metadata: in a rill.yaml defaults: block does not apply, same as tags: today; the generated docs say so.

Shape note: values are kept a flat map[string]string so they serialize losslessly into an Apache Ossie custom_extensions entry (vendor_name: RILL, data is a JSON string) if we add an Ossie importer/exporter later.

No catalog migration is needed, since ResourceMeta is persisted as an opaque proto blob. The large resources.pb.go diff is the nested MetadataEntry message renumbering every msgTypes index below it.

Related to #9794.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

https://claude.ai/code/session_01FvtFG1k64JW9SpV8aCH5Se

Adds a top-level `metadata:` map to every resource YAML, parsed generically
in `commonYAML` and stored on `ResourceMeta.metadata`, mirroring `tags:`.

- Values are strings; non-string scalars are coerced (`tier: 1` -> "1") and
  nulls become "". Non-scalar values are a parse error naming the key.
- Strict validation is otherwise unchanged: unknown fields still error.
- Exposed over `GetResource`/`ListResources`/`WatchResources` on `meta`.
- Also settable from SQL annotations (`-- @metadata.owner: alice`).
- Auto-generated inline explores inherit the metrics view's metadata.

Claude-Session: https://claude.ai/code/session_01FvtFG1k64JW9SpV8aCH5Se
@nishantmonu51
nishantmonu51 marked this pull request as ready for review September 9, 2026 13:49
Assigning the shared `err` on every successful metadata key could overwrite
an error set by an earlier annotation case. Map iteration order is random,
so an invalid `-- @name:` or `-- @connector:` could be silently dropped.

Claude-Session: https://claude.ai/code/session_01FvtFG1k64JW9SpV8aCH5Se
Comment thread proto/rill/runtime/v1/resources.proto Outdated
// Metadata is user-defined key-value metadata. Parsed generically from any resource YAML's top-level "metadata:" field.
// Rill does not interpret it; it is exposed here for external tooling.
// It maps to an Apache Ossie `custom_extensions` entry with vendor_name "RILL" and data `{"metadata": {...}}`.
map<string, string> metadata = 20;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

metadata feels too generic and does not specify that Rill ignores this especially given the outer field is also called meta.
Some suggestions:
extensions/ext: Used for vendor specific fields in specs like OpenRTB.
ext_metadata: Again emphasis on the fact that this is external metadata and not Rill specific metadata.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We can have rill specific metadata as well here e.g. whether the resource is AI generated or edited by human etc.. so, would like to start with metadata for now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Keeping metadata per the above, but reworded the docstring (and the schema description, generated docs and TS types) so it no longer claims Rill ignores the field: it now says it is free-form key-value metadata, currently user-defined, and that Rill may populate its own keys later (e.g. provenance).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rill putting its own keys in a field that it never parses and stores and forwards as black box seems to be an anti-pattern IMO.
It can also lead to edge cases/complex handling like how do we merge user's metadata with Rill's metadata.

Comment thread runtime/parser/parse_node.go Outdated
Addresses review feedback: yaml.v3 already coerces non-string scalars into
string targets, and the SQL annotation path already goes through
mapstructure with WeaklyTypedInput, so the custom decoder was redundant.
Also rewords the field docstring and drops the Ossie mapping note from it.

Claude-Session: https://claude.ai/code/session_01FvtFG1k64JW9SpV8aCH5Se
Comment thread proto/rill/runtime/v1/resources.proto Outdated
// Tags for organizing and filtering resources. Parsed generically from any resource YAML's top-level "tags:" field.
repeated string tags = 19;
// Metadata is free-form key-value metadata for the resource, parsed generically from any resource YAML's top-level "metadata:" field.
// It is currently user-defined and exposed as-is over the API, but Rill may also populate its own keys in the future (e.g. provenance).

@k-anshul k-anshul Sep 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As noted in other comment Rill putting its own keys in metadata is an anti pattern and prone to complications :

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.

2 participants