YoannAbriel commented on code in PR #63343:
URL: https://github.com/apache/airflow/pull/63343#discussion_r3035373340
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_variables.py:
##########
@@ -254,6 +254,38 @@ def test_get_should_respond_404(self, test_client):
body = response.json()
assert f"The Variable with key: `{TEST_VARIABLE_KEY}` was not found"
== body["detail"]
+ def test_get_variable_with_undecryptable_val(self, test_client, session):
+ """Variable with an undecryptable _val (e.g. migrated with a different
Fernet key) should
+ return 200 with value=None instead of raising a 500 serialization
error."""
+ var = Variable(key="bad_encrypted_var")
+ var._val = "not-a-valid-fernet-token"
+ var.is_encrypted = True
+ var.description = "migrated variable"
+ session.add(var)
+ session.commit()
+
+ response = test_client.get("/variables/bad_encrypted_var")
+ assert response.status_code == 200
+ body = response.json()
+ assert body["key"] == "bad_encrypted_var"
+ assert body["value"] is None
+
+ def test_get_variables_with_undecryptable_val(self, test_client, session):
Review Comment:
Moved to TestGetVariables.
--
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]