saitejabandaru-in commented on issue #71810: URL: https://github.com/apache/airflow/issues/71810#issuecomment-5342932869
Since `Variable.set` currently behaves like an upsert (`ON CONFLICT (key) DO UPDATE`) based exclusively on `key`, it blindly overwrites the existing row matching the `key`, including its `team_name`. Because `key` alone is marked as `unique=True` in the database schema, Airflow does not treat `team_name` as a namespace partition. The same key cannot exist across different teams. This is arguably a design flaw in how the new `core.multi_team` feature was integrated with `Variable.set()`. A global/shared variable (where `team_name=None`) should probably have its ownership preserved upon a value-only update, or at the very least, updating a variable owned by `team_a` shouldn't silently steal ownership if the updater doesn't explicitly intend to do so. To fix this, `Variable.set` could be updated so that `team_name` is excluded from the `update_fields` of `build_upsert_stmt` during an upsert if `team_name` is not explicitly passed (or perhaps ownership transfers should be blocked entirely on upserts unless explicitly requested). Alternatively, if the intention of multi-team is full logical isolation, the database unique constraint should arguably be `(key, team_name)` rather than just `key`, which would allow true multi-tenant namespace isolation for variables (so `team_a` and `team_b` can both have a variable named `k`). But that would be a larger breaking schema change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
