Repository navigation
fix: Enforce required_tags and lineage RBAC, and store BatchFeatureView UDF changes - #7191
Conversation
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| from feast.batch_feature_view import BatchFeatureView | ||
| # BatchFeatureView.from_proto must restore the transformation too, or | ||
| # `feast apply` compares a new UDF against a stored copy that has none. | ||
| if has_transformation and cls in (FeatureView, BatchFeatureView): |
There was a problem hiding this comment.
🔴 Reapplied batch views crash during deserialization
Reapplying SQL or Flink batch views through Registry.apply_feature_view now raises AttributeError. Neither SQLTransformation nor FlinkTransformation implements from_proto, and the dispatch only catches ValueError and KeyError. Even unchanged definitions cannot be reapplied.
Learn more
The file registry calls the incoming view's concrete class to restore an existing definition before comparing changes in Registry.apply_feature_view. Previously, BatchFeatureView bypassed transformation reconstruction there. The expanded condition now dispatches restoration through the mode-specific class selected by get_transformation_class_from_type. SQLTransformation and FlinkTransformation have no from_proto, including through their Transformation base. Calling that missing method raises AttributeError, which escapes the existing exception handler; Spark wrappers have the same missing deserializer.
Example: Apply a BatchFeatureView with a FileSource, an explicit schema, mode="sql", and a SQL-producing UDF through Registry.apply_feature_view. Applying the identical definition again enters transformation restoration and raises AttributeError: type object 'SQLTransformation' has no attribute 'from_proto'.
Recommended fix: Provide mode-preserving deserialization for every supported transformation wrapper before routing BatchFeatureView restoration through this dispatch. Add round-trip and repeated-apply tests for SQL and Flink, and cover Spark when its dependencies are available. Simply swallowing AttributeError or discarding the transformation would leave the persisted definition incorrect.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7191 +/- ##
==========================================
+ Coverage 53.82% 54.04% +0.22%
==========================================
Files 462 466 +4
Lines 58639 58870 +231
Branches 8651 8671 +20
==========================================
+ Hits 31562 31819 +257
+ Misses 24938 24902 -36
- Partials 2139 2149 +10
... and 7 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
franciscojavierarceo
left a comment
There was a problem hiding this comment.
we need to handle source-less UDF changes and the remaining graph symlink disclosure before merging.
| # text, or the bytecode when there is no source text. | ||
| if new.udf_string and old.udf_string: | ||
| return new.udf_string != old.udf_string | ||
| return new.udf.__code__.co_code != old.udf.__code__.co_code |
There was a problem hiding this comment.
co_code excludes constants and captured values. with the default empty udf_string, SQL UDFs lambda _: "SELECT 1" and lambda _: "SELECT 2" have the same bytecode, so this reports no change and Registry.apply_feature_view takes its metadata-only return, retaining the old query. we need a comparison that includes the callable's relevant constants, defaults and closure state, plus a repeated-apply regression without source text.
There was a problem hiding this comment.
Good point. The same co_code-only fallback is already in the other transformations' eq and in the stream view check, so would you be okay with me fixing it for all types (consts, defaults, closures) in a follow-up PR rather than only here?
There was a problem hiding this comment.
we can handle the other transformation types in a follow-up. we need the new BatchFeatureView comparison here to detect constants, defaults and closures, with an empty-udf_string repeated-apply regression; otherwise the apply bug this PR fixes still leaves changed SQL UDFs stored unchanged.
| @@ -513,7 +513,8 @@ def _get_namespace_filter(ns_callable) -> Optional[List[str]]: | |||
| try: | |||
| return ns_callable() | |||
| except Exception: | |||
There was a problem hiding this comment.
returning [] still leaves a lineage read path open: get_full_lineage_graph calls store.get_all_symlinks() without a namespace filter, returns those records and appends them to edges. a user with no allowed projects, including a failed permission check, can still read dataset names and namespaces from other teams through /lineage/openlineage/graph. we need to filter symlinks by authorized endpoints and cover this endpoint with denied-access and mixed-namespace regressions.
franciscojavierarceo
left a comment
There was a problem hiding this comment.
the CI type-check failure also needs a code change in the new deserialization API.
|
|
||
| @classmethod | ||
| def from_proto( | ||
| cls, user_defined_function_proto: UserDefinedFunctionProto |
There was a problem hiding this comment.
the full type check now fails because this inherited from_proto contract takes UserDefinedFunctionV2, while SubstraitTransformation.from_proto overrides it with SubstraitTransformationV2: CI reports an incompatible override. we need an override-compatible deserialization contract for these distinct proto types so the existing Substrait implementation and the new SQL/Flink restoration both pass type checking.
…ew UDF changes - Match Permission.required_tags against resource.tags. The matcher read a required_tags attribute that resources do not have, so tag-scoped permissions matched every resource. List filtering now also skips resources outside a tag-scoped permission instead of failing the list. - Lineage RBAC no longer fails open: when a user is allowed no namespaces, or the permission check errors, lineage is hidden instead of showing every namespace. Fixed in the lineage server, the REST API that feast ui uses, and the lineage store, where an empty list now means "nothing". - feast apply now detects BatchFeatureView UDF changes, and BatchFeatureView.from_proto restores the transformation, so the file registry stores the new UDF instead of keeping the old one. Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
SQLTransformation and FlinkTransformation had no from_proto, so reading a SQL or Flink BatchFeatureView from the registry raised AttributeError, and since BatchFeatureView.from_proto now restores the transformation, re-applying one did too. Add a mode-preserving from_proto to the base Transformation, and compare SQL and Flink UDFs by source text so an unchanged re-apply stays a metadata-only update. Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
…roto typing - /lineage/openlineage/graph returned every dataset symlink and kept edges with only one end in an allowed namespace, so a user without access could still read other teams' dataset names and namespaces. With RBAC on, symlinks and edges are now returned only when both ends are in namespaces the caller may see. - The base Transformation.from_proto clashed with SubstraitTransformation's override (different proto type) and failed the type check. Move the shared UDF restore into udf_transformation_from_proto and give SQL, Flink and Spark their own from_proto that calls it. Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
With an empty udf_string, the change check compared only co_code, which leaves out constants, default arguments and closure values. So `lambda _: "SELECT 1"` and `lambda _: "SELECT 2"` looked the same, feast apply took the metadata-only path and kept the old query. Compare the whole code object (which includes constants), the defaults and the closure values instead, and add an empty-udf_string re-apply regression. Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
60d6fc1 to
3c16720
Compare
I was testing RBAC in the Feast UI with a real OIDC login and ran into a few holes, plus one
feast applybug.What was wrong
required_tagson aPermissionwas never checked. The matcher looked forresource.required_tags, which resources don't have, so a "team=risk only" permission matched everything.name_patterns. It now does the same forrequired_tags.None, which means "no filter", so they saw every namespace. Fixed in the lineage server, the REST API thatfeast uiuses, and the lineage store.feast applydidn't store BatchFeatureView UDF changes on the file registry. The change check never compared the UDF, andBatchFeatureView.from_protodropped it.Before / after
Top:
risk-analystmay only see resources taggedteam=risk. Bottom:internhas no permissions and opens Lineage.Tests
One unit test per fix, and each one fails without its fix.