Skip to content

Commit b511b8f

Browse files
test fixes
1 parent d72f7ec commit b511b8f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • airflow-core/src/airflow/api_fastapi/execution_api

airflow-core/src/airflow/api_fastapi/execution_api/app.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ class InProcessExecutionAPI:
296296
@cached_property
297297
def app(self):
298298
if not self._app:
299+
import os
300+
from base64 import urlsafe_b64encode
301+
299302
from airflow.api_fastapi.common.dagbag import create_dag_bag
300303
from airflow.api_fastapi.execution_api.app import create_task_execution_api_app
301304
from airflow.api_fastapi.execution_api.deps import (
@@ -306,6 +309,16 @@ def app(self):
306309
from airflow.api_fastapi.execution_api.routes.task_instances import JWTBearerWorkloadDep
307310
from airflow.api_fastapi.execution_api.routes.variables import has_variable_access
308311
from airflow.api_fastapi.execution_api.routes.xcoms import has_xcom_access
312+
from airflow.configuration import conf
313+
314+
# Ensure JWT secret is available for in-process execution.
315+
# The /run endpoint needs JWTGenerator to issue execution tokens.
316+
# If the config option is empty, generate a random one for the duration of this process.
317+
if not conf.get("api_auth", "jwt_secret", fallback=None):
318+
logger.debug(
319+
"`api_auth/jwt_secret` is not set, generating a temporary one for in-process execution"
320+
)
321+
conf.set("api_auth", "jwt_secret", urlsafe_b64encode(os.urandom(16)).decode())
309322

310323
self._app = create_task_execution_api_app()
311324

0 commit comments

Comments
 (0)