Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate reserved metadata value types #26746

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

clairelin135
Copy link
Contributor

@clairelin135 clairelin135 commented Dec 27, 2024

Summary & Motivation

Validate dagster-reserved metadata value types upon construction. Our code assumes that reserved metadata values have the correct type (i.e. dagster/column_schema is a TableSchema object), let's enforce that.

How I Tested These Changes

BK

Changelog

Adds type validation for reserved metadata keys defined in asset definitions and MaterializeResult.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@clairelin135 clairelin135 force-pushed the 12-27-claire/validate-reserved-metadata-types branch 3 times, most recently from 854f327 to 4755709 Compare December 27, 2024 21:25
@clairelin135 clairelin135 marked this pull request as ready for review December 27, 2024 21:36
@clairelin135 clairelin135 force-pushed the 12-27-claire/validate-reserved-metadata-types branch from 4755709 to 7ed489e Compare December 27, 2024 21:39
@clairelin135 clairelin135 force-pushed the 12-27-claire/validate-reserved-metadata-types branch from 7ed489e to ebb59a7 Compare December 27, 2024 21:41
Copy link
Member

@gibsondan gibsondan left a comment

Choose a reason for hiding this comment

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

Do we need to worry at all about this being a breaking change for existing code / potentially start with a warning and roll this out in 1.10 if so? Or is it clearly an invalid state and this is basically just a bugfix?

@clairelin135
Copy link
Contributor Author

IMO it's an invalid state and from backend search we know that it affects very few users. When users are emitting invalid metadata types like this they also can't see table schema metadata in the UI etc. so we should block this behavior.

Copy link
Member

@gibsondan gibsondan left a comment

Choose a reason for hiding this comment

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

we may want to reach out to the specific folks that triggered us noticing this so they don't get surprised when they upgrade, just as a courtesy

Comment on lines +135 to +156
def test_error_on_invalid_reserved_metadata_value():
with pytest.raises(
CheckError, match="Value for metadata key 'dagster/column_schema' must be a TableSchema"
):

@asset(
metadata={
"dagster/column_schema": "invalid",
}
)
def foo():
pass

@asset()
def bar():
yield MaterializeResult(metadata={"dagster/column_schema": "invalid"})

defs = Definitions(assets=[bar])
with pytest.raises(
CheckError, match="Value for metadata key 'dagster/column_schema' must be a TableSchema"
):
defs.get_implicit_global_asset_job_def().execute_in_process()
Copy link
Member

Choose a reason for hiding this comment

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

should we include tests that cover the other values we added validation for?

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