{"id":23731,"plugin_id":"plugins_6ab2f25e4928819184294ebadcbe38ab","kind":"skill","collection_source":null,"comparison_source":null,"observed_at":"2026-09-30T23:17:46.000Z","digest":"10bcd2839bcda65ab18347be9a251018a1865a0b1c8fcee84a53924c2fed2e46","against":null,"payload":{"name":"airflow-plugins","description":"Builds Airflow 3.1+ plugins that embed FastAPI apps, custom UI pages, React components, middleware, macros, and operator links directly into the Airflow UI. Use when building anything custom inside Airflow 3.1+ that involves Python and a browser-facing interface - creating an Airflow plugin, adding a custom UI page or nav entry, building FastAPI-backed endpoints inside Airflow, serving static assets from a plugin, embedding a React app, adding middleware to the API server, creating custom operator extra links, or calling the Airflow REST API from inside a plugin; also when AirflowPlugin, fastapi_apps, external_views, react_apps, or plugin registration come up.","included_files":[],"skill_md_contents":"---\nname: airflow-plugins\ndescription: Builds Airflow 3.1+ plugins that embed FastAPI apps, custom UI pages, React components, middleware, macros, and operator links directly into the Airflow UI. Use when building anything custom inside Airflow 3.1+ that involves Python and a browser-facing interface - creating an Airflow plugin, adding a custom UI page or nav entry, building FastAPI-backed endpoints inside Airflow, serving static assets from a plugin, embedding a React app, adding middleware to the API server, creating custom operator extra links, or calling the Airflow REST API from inside a plugin; also when AirflowPlugin, fastapi_apps, external_views, react_apps, or plugin registration come up.\n---\n\n# Airflow 3 Plugins\n\nAirflow 3 plugins let you embed FastAPI apps, React UIs, middleware, macros, operator buttons, and custom timetables directly into the Airflow process. No sidecar, no extra server.\n\n> **CRITICAL**: Plugin components (fastapi_apps, react_apps, external_views) require **Airflow 3.1+**. **NEVER import `flask`, `flask_appbuilder`, or use `appbuilder_views` / `flask_blueprints`** — these are Airflow 2 patterns and will not work in Airflow 3. If existing code uses them, rewrite the entire registration block using FastAPI.\n>\n> **Security**: FastAPI plugin endpoints are **not automatically protected** by Airflow auth. If your endpoints need to be private, implement authentication explicitly using FastAPI's security utilities.\n>\n> **Restart required**: Changes to Python plugin files require restarting the API server. Static file changes (HTML, JS, CSS) are picked up immediately. Set `AIRFLOW__CORE__LAZY_LOAD_PLUGINS=False` during development to load plugins at startup rather than lazily.\n>\n> **Relative paths always**: In `external_views`, `href` must have no leading slash. In HTML and JavaScript, use relative paths for all assets and `fetch()` calls. Absolute paths break behind reverse proxies.\n\n### Before writing any code, verify\n\n1. Am I using `fastapi_apps` / FastAPI — not `appbuilder_views` / Flask?\n2. Are all HTML/JS asset paths and `fetch()` calls relative (no leading slash)?\n3. Are all synchronous SDK or SQLAlchemy calls wrapped in `asyncio.to_thread()`?\n4. Do the `static/` and `assets/` directories exist before the FastAPI app mounts them?\n5. If the endpoint must be private, did I add explicit FastAPI authentication?\n\n---\n\n## Step 1: Choose plugin components\n\nA single plugin class can register multiple component types at once.\n\n| Component | What it does | Field |\n|-----------|-------------|-------|\n| Custom API endpoints | FastAPI app mounted in Airflow process | `fastapi_apps` |\n| Nav / page link | Embeds a URL as an iframe or links out | `external_views` |\n| React component | Custom React app embedded in Airflow UI | `react_apps` |\n| API middleware | Intercepts all Airflow API requests/responses | `fastapi_root_middlewares` |\n| Jinja macros | Reusable Python functions in DAG templates | `macros` |\n| Task instance button | Extra link button in task Detail view | `operator_extra_links` / `global_operator_extra_links` |\n| Custom timetable | Custom scheduling logic | `timetables` |\n| Event hooks | Listener callbacks for Airflow events | `listeners` |\n\n---\n\n## Step 2: Plugin registration skeleton\n\n### Project file structure\n\nGive each plugin its own subdirectory under `plugins/` — this keeps the Python file, static assets, and templates together and makes multi-plugin projects manageable:\n\n```\nplugins/\n  my-plugin/\n    plugin.py       # AirflowPlugin subclass — auto-discovered by Airflow\n    static/\n      index.html\n      app.js\n    assets/\n      icon.svg\n```\n\n`BASE_DIR = Path(__file__).parent` in `plugin.py` resolves to `plugins/my-plugin/` — static and asset paths will be correct relative to that. Create the subdirectory and any static/assets folders before starting Airflow, or `StaticFiles` will raise on import.\n\n```python\nfrom pathlib import Path\nfrom airflow.plugins_manager import AirflowPlugin\nfrom fastapi import FastAPI\nfrom fastapi.staticfiles import StaticFiles\nfrom fastapi.responses import FileResponse\n\nBASE_DIR = Path(__file__).parent\n\napp = FastAPI(title=\"My Plugin\")\n\n# Both directories must exist before Airflow starts or FastAPI raises on import\napp.mount(\"/static\", StaticFiles(directory=BASE_DIR / \"static\"), name=\"static\")\napp.mount(\"/assets\", StaticFiles(directory=BASE_DIR / \"assets\"), name=\"assets\")\n\n\nclass MyPlugin(AirflowPlugin):\n    name = \"my_plugin\"\n\n    fastapi_apps = [\n        {\n            \"app\": app,\n            \"url_prefix\": \"/my-plugin\",   # plugin available at {AIRFLOW_HOST}/my-plugin/\n            \"name\": \"My Plugin\",\n        }\n    ]\n\n    external_views = [\n        {\n            \"name\": \"My Plugin\",\n            \"href\": \"my-plugin/ui\",              # NO leading slash — breaks on Astro and reverse proxies\n            \"destination\": \"nav\",                # see locations table below\n            \"category\": \"browse\",                # nav bar category (nav destination only)\n            \"url_route\": \"my-plugin\",            # unique route name (required for React apps)\n            \"icon\": \"/my-plugin/static/icon.svg\" # DOES use a leading slash — served by FastAPI\n        }\n    ]\n```\n\n### External view locations\n\n| `destination` | Where it appears |\n|--------------|-----------------|\n| `\"nav\"` | Left navigation bar (also set `category`) |\n| `\"dag\"` | Extra tab on every Dag page |\n| `\"dag_run\"` | Extra tab on every Dag run page |\n| `\"task\"` | Extra tab on every task page |\n| `\"task_instance\"` | Extra tab on every task instance page |\n\n### Nav bar categories (`destination: \"nav\"`)\n\nSet `\"category\"` to place the link under a specific nav group: `\"browse\"`, `\"admin\"`, or omit for top-level.\n\n### External URLs and minimal plugins\n\n`href` can be a relative path to an internal endpoint (`\"my-plugin/ui\"`) or a full external URL. A plugin with only `external_views` and no `fastapi_apps` is valid — no backend needed for a simple link or tab:\n\n```python\nfrom airflow.plugins_manager import AirflowPlugin\n\nclass LearnViewPlugin(AirflowPlugin):\n    name = \"learn_view_plugin\"\n\n    external_views = [\n        {\n            \"name\": \"Learn Airflow 3\",\n            \"href\": \"https://www.astronomer.io/docs/learn\",\n            \"destination\": \"dag\",   # adds a tab to every Dag page\n            \"url_route\": \"learn\"\n        }\n    ]\n```\n\nThe no-leading-slash rule applies to internal paths only — full `https://` URLs are fine.\n\n---\n\n## Step 3: Serve the UI entry point\n\n```python\n@app.get(\"/ui\", response_class=FileResponse)\nasync def serve_ui():\n    return FileResponse(BASE_DIR / \"static\" / \"index.html\")\n```\n\nIn HTML, always use **relative paths**. Absolute paths break when Airflow is mounted at a sub-path:\n\n```html\n<!-- correct -->\n<link rel=\"stylesheet\" href=\"static/app.css\" />\n<script src=\"static/app.js?v=20240315\"></script>\n\n<!-- breaks behind a reverse proxy -->\n<script src=\"/my-plugin/static/app.js\"></script>\n```\n\nSame rule in JavaScript:\n\n```javascript\nfetch('api/dags')           // correct — relative to current page\nfetch('/my-plugin/api/dags') // breaks on Astro and sub-path deploys\n```\n\n---\n\n## Step 4: Call the Airflow API from your plugin\n\n> **Only needed if your plugin calls the Airflow REST API.** Plugins that only serve static files, register `external_views`, or use direct DB access do not need this step — skip to Step 5 or Step 6.\n\n### Add the dependency\n\nOnly if REST API communication is being implemented: add `apache-airflow-client` to the project's dependencies. Check which file exists and act accordingly:\n\n| File found | Action |\n|------------|--------|\n| `requirements.txt` | Append `apache-airflow-client` |\n| `pyproject.toml` (uv / poetry) | `uv add apache-airflow-client` or `poetry add apache-airflow-client` |\n| None of the above | Tell the user: \"Add `apache-airflow-client` to your dependencies before running the plugin.\" |\n\nUse `apache-airflow-client` to talk to Airflow's own REST API. The SDK is **synchronous** but FastAPI routes are async — never call blocking SDK methods directly inside `async def` or you will stall the event loop and freeze all concurrent requests.\n\n### JWT token management\n\nCache one token per process. Refresh 5 minutes before the 1-hour expiry. Use double-checked locking so multiple concurrent requests don't all race to refresh simultaneously:\n\n> Replace `MYPLUGIN_` with a short uppercase prefix derived from the plugin name (e.g. if the plugin is called \"Trip Analyzer\", use `TRIP_ANALYZER_`). If no plugin name has been given yet, ask the user before writing env var names.\n\n```python\nimport asyncio\nimport os\nimport threading\nimport time\nimport airflow_client.client as airflow_sdk\nimport requests\n\nAIRFLOW_HOST  = os.environ.get(\"MYPLUGIN_HOST\",     \"http://localhost:8080\")\nAIRFLOW_USER  = os.environ.get(\"MYPLUGIN_USERNAME\", \"admin\")\nAIRFLOW_PASS  = os.environ.get(\"MYPLUGIN_PASSWORD\", \"admin\")\nAIRFLOW_TOKEN = os.environ.get(\"MYPLUGIN_TOKEN\")    # Astronomer Astro: Deployment API token\n\n_cached_token: str | None = None\n_token_expires_at: float  = 0.0\n_token_lock = threading.Lock()\n\n\ndef _fetch_fresh_token() -> str:\n    \"\"\"Exchange username/password for a JWT via Airflow's auth endpoint.\"\"\"\n    response = requests.post(\n        f\"{AIRFLOW_HOST}/auth/token\",\n        json={\"username\": AIRFLOW_USER, \"password\": AIRFLOW_PASS},\n        timeout=10,\n    )\n    response.raise_for_status()\n    return response.json()[\"access_token\"]\n\n\ndef _get_token() -> str:\n    # Astronomer Astro production: use static Deployment API token directly\n    if AIRFLOW_TOKEN:\n        return AIRFLOW_TOKEN\n    global _cached_token, _token_expires_at\n    now = time.monotonic()\n    # Fast path — no lock if still valid\n    if _cached_token and now < _token_expires_at:\n        return _cached_token\n    # Slow path — one thread refreshes, others wait\n    with _token_lock:\n        if _cached_token and now < _token_expires_at:\n            return _cached_token\n        _cached_token = _fetch_fresh_token()\n        _token_expires_at = now + 55 * 60  # refresh 5 min before 1-hour expiry\n    return _cached_token\n\n\ndef _make_config() -> airflow_sdk.Configuration:\n    config = airflow_sdk.Configuration(host=AIRFLOW_HOST)\n    config.access_token = _get_token()\n    return config\n```\n\nAfter implementing auth, tell the user:\n\n- **Local development**: set `MYPLUGIN_USERNAME` and `MYPLUGIN_PASSWORD` in `.env` — JWT exchange happens automatically.\n- **Astronomer Astro (production)**: create a Deployment API token and set it as `MYPLUGIN_TOKEN` — the JWT exchange is skipped entirely:\n  1. Astro UI → open the Deployment → **Access** → **API Tokens** → **+ Deployment API Token**\n  2. Copy the token value (shown only once)\n  3. `astro deployment variable create MYPLUGIN_TOKEN=<token>`\n\n  `MYPLUGIN_USERNAME` and `MYPLUGIN_PASSWORD` are not needed on Astro.\n\n### Wrapping SDK calls with asyncio.to_thread\n\n```python\nfrom fastapi import HTTPException\nfrom airflow_client.client.api import DAGApi\n\n@app.get(\"/api/dags\")\nasync def list_dags():\n    try:\n        def _fetch():\n            with airflow_sdk.ApiClient(_make_config()) as client:\n                return DAGApi(client).get_dags(limit=100).dags\n        dags = await asyncio.to_thread(_fetch)\n        return [{\"dag_id\": d.dag_id, \"is_paused\": d.is_paused, \"timetable_summary\": d.timetable_summary} for d in dags]\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n```\n\n> **API field names**: Never guess response field names — verify against the [REST API reference](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html). Key `DAGResponse` fields: `dag_id`, `dag_display_name`, `description`, `is_paused`, `timetable_summary`, `timetable_description`, `fileloc`, `owners`, `tags`.\n\nThe pattern is always: define a plain inner `def _fetch()` with all SDK logic, then `await asyncio.to_thread(_fetch)`.\n\n### Alternative: Direct database access\n\n> **Warning — use with caution and tell the user.** The Airflow metadb is not a public interface. Direct writes or poorly-formed queries can corrupt scheduler state. Whenever you use this pattern, explicitly tell the user: \"This accesses Airflow's internal database directly. The internal models are not part of the public API, can change between Airflow versions, and incorrect queries can cause issues in the metadb. Prefer `apache-airflow-client` unless the operation is not exposed via the REST API.\"\n\nSince FastAPI plugin endpoints run inside the **API server process** (not in a task worker), they have direct access to Airflow's internal SQLAlchemy models — no HTTP round-trip or JWT needed. Use only for read operations not exposed via the REST API, or when the extra HTTP overhead genuinely matters. Always wrap DB calls in `asyncio.to_thread()` — SQLAlchemy queries are blocking.\n\n```python\nfrom airflow.models import DagBag, DagModel\nfrom airflow.utils.db import provide_session\n\n@app.get(\"/api/dags/status\")\nasync def dag_status():\n    def _fetch():\n        @provide_session\n        def _query(session=None):\n            dagbag = DagBag()\n            paused = sum(\n                1 for dag_id in dagbag.dags\n                if (m := session.query(DagModel).filter(DagModel.dag_id == dag_id).first())\n                and m.is_paused\n            )\n            return {\"total\": len(dagbag.dags), \"paused\": paused}\n        return _query()\n    return await asyncio.to_thread(_fetch)\n```\n\n---\n\n## Step 5: Common API endpoint patterns\n\n> **If you need an SDK method or field not shown in the examples below**, verify it before generating code — do not guess. Either run `python3 -c \"from airflow_client.client.api import <Class>; print([m for m in dir(<Class>) if not m.startswith('_')])\"` in any environment where the SDK is installed, or search the [`apache/airflow-client-python`](https://github.com/apache/airflow-client-python) repo for the class definition.\n\n```python\nfrom airflow_client.client.api import DAGApi, DagRunApi\nfrom airflow_client.client.models import TriggerDAGRunPostBody, DAGPatchBody\n\n\n@app.post(\"/api/dags/{dag_id}/trigger\")\nasync def trigger_dag(dag_id: str):\n    def _run():\n        with airflow_sdk.ApiClient(_make_config()) as client:\n            return DagRunApi(client).trigger_dag_run(dag_id, TriggerDAGRunPostBody())\n    result = await asyncio.to_thread(_run)\n    return {\"run_id\": result.dag_run_id, \"state\": normalize_state(result.state)}\n\n\n@app.patch(\"/api/dags/{dag_id}/pause\")\nasync def toggle_pause(dag_id: str, is_paused: bool):\n    def _run():\n        with airflow_sdk.ApiClient(_make_config()) as client:\n            DAGApi(client).patch_dag(dag_id, DAGPatchBody(is_paused=is_paused))\n    await asyncio.to_thread(_run)\n    return {\"dag_id\": dag_id, \"is_paused\": is_paused}\n\n\n@app.delete(\"/api/dags/{dag_id}\")\nasync def delete_dag(dag_id: str):\n    def _run():\n        with airflow_sdk.ApiClient(_make_config()) as client:\n            DAGApi(client).delete_dag(dag_id)\n    await asyncio.to_thread(_run)\n    return {\"deleted\": dag_id}\n\n\ndef normalize_state(raw) -> str:\n    \"\"\"Convert SDK enum objects to plain strings before sending to the frontend.\"\"\"\n    if raw is None:\n        return \"never_run\"\n    return str(raw).lower()\n```\n\n### DAG runs, task instances, and logs\n\nThese are the most common calls beyond basic DAG CRUD. For anything not shown here, consult the [REST API reference](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html) for available endpoints and the matching Python SDK class/method names.\n\n```python\nfrom airflow_client.client.api import DagRunApi, TaskInstanceApi\n\n# Latest run for a DAG\n@app.get(\"/api/dags/{dag_id}/runs/latest\")\nasync def latest_run(dag_id: str):\n    def _fetch():\n        with airflow_sdk.ApiClient(_make_config()) as client:\n            runs = DagRunApi(client).get_dag_runs(dag_id, limit=1, order_by=\"-start_date\").dag_runs\n            return runs[0] if runs else None\n    run = await asyncio.to_thread(_fetch)\n    if not run:\n        return {\"state\": \"never_run\"}\n    return {\"run_id\": run.dag_run_id, \"state\": normalize_state(run.state)}\n\n\n# Task instances for a specific run\n@app.get(\"/api/dags/{dag_id}/runs/{run_id}/tasks\")\nasync def task_instances(dag_id: str, run_id: str):\n    def _fetch():\n        with airflow_sdk.ApiClient(_make_config()) as client:\n            return TaskInstanceApi(client).get_task_instances(dag_id, run_id).task_instances\n    tasks = await asyncio.to_thread(_fetch)\n    return [{\"task_id\": t.task_id, \"state\": normalize_state(t.state)} for t in tasks]\n\n\n# Task log (try_number starts at 1)\n@app.get(\"/api/dags/{dag_id}/runs/{run_id}/tasks/{task_id}/logs/{try_number}\")\nasync def task_log(dag_id: str, run_id: str, task_id: str, try_number: int):\n    def _fetch():\n        with airflow_sdk.ApiClient(_make_config()) as client:\n            return TaskInstanceApi(client).get_log(\n                dag_id, run_id, task_id, try_number, map_index=-1\n            )\n    result = await asyncio.to_thread(_fetch)\n    return {\"log\": result.content if hasattr(result, \"content\") else str(result)}\n```\n\n### Streaming proxy\n\nUse `StreamingResponse` to proxy binary content from an external URL through the plugin — useful when the browser can't fetch the resource directly (CORS, auth, etc.):\n\n```python\nimport requests\nfrom starlette.responses import StreamingResponse\n\n@app.get(\"/api/files/{filename}\")\nasync def proxy_file(filename: str):\n    def _stream():\n        r = requests.get(f\"https://files.example.com/{filename}\", stream=True)\n        r.raise_for_status()\n        return r\n    response = await asyncio.to_thread(_stream)\n    return StreamingResponse(\n        response.iter_content(chunk_size=8192),\n        media_type=\"application/octet-stream\",\n        headers={\"Content-Disposition\": f'attachment; filename=\"{filename}\"'},\n    )\n```\n\nNote that `requests.get()` is blocking — fetch in `asyncio.to_thread` so the event loop isn't stalled while waiting for the remote server.\n\n---\n\n## Step 6: Other plugin component types\n\n### Macros\n\nMacros are loaded by the **scheduler** (and DAG processor), not the API server. Restart the scheduler after changes.\n\n```python\nfrom airflow.plugins_manager import AirflowPlugin\n\ndef format_confidence(confidence: float) -> str:\n    return f\"{confidence * 100:.2f}%\"\n\nclass MyPlugin(AirflowPlugin):\n    name = \"my_plugin\"\n    macros = [format_confidence]\n```\n\nUse in any templated field — including with XCom:\n\n```\n{{ macros.my_plugin.format_confidence(0.95) }}\n\n{{ macros.my_plugin.format_confidence(ti.xcom_pull(task_ids='score_task')['confidence']) }}\n```\n\nThe naming pattern is always `macros.{plugin_name}.{function_name}`.\n\n### Middleware\n\nMiddleware applies to **all** Airflow API requests, including the built-in REST API and any FastAPI plugins. Use sparingly and filter requests explicitly if needed:\n\n```python\nfrom starlette.middleware.base import BaseHTTPMiddleware\nfrom fastapi import Request, Response\n\nclass AuditMiddleware(BaseHTTPMiddleware):\n    async def dispatch(self, request: Request, call_next) -> Response:\n        # runs before every request to the Airflow API server\n        response = await call_next(request)\n        return response\n\nclass MyPlugin(AirflowPlugin):\n    name = \"my_plugin\"\n    fastapi_root_middlewares = [\n        {\"middleware\": AuditMiddleware, \"args\": [], \"kwargs\": {}, \"name\": \"Audit\"}\n    ]\n```\n\n### Operator extra links\n\n```python\nfrom airflow.sdk.bases.operatorlink import BaseOperatorLink\n\nclass MyDashboardLink(BaseOperatorLink):\n    name = \"Open in Dashboard\"\n\n    def get_link(self, operator, *, ti_key, **context) -> str:\n        return f\"https://my-dashboard.example.com/tasks/{ti_key.task_id}\"\n\nclass MyPlugin(AirflowPlugin):\n    name = \"my_plugin\"\n    global_operator_extra_links = [MyDashboardLink()]  # appears on every task\n    # operator_extra_links = [MyDashboardLink()]       # attach to specific operator instead\n```\n\n### React apps\n\nReact apps are embedded as JavaScript bundles served via FastAPI. The bundle must expose itself as a global variable matching the plugin name:\n\n```javascript\n// In your bundle (e.g. my-app.js)\nglobalThis['My Plugin'] = MyComponent;   // matches plugin name\nglobalThis.AirflowPlugin = MyComponent;  // fallback Airflow looks for\n```\n\n```python\nclass MyPlugin(AirflowPlugin):\n    name = \"my_plugin\"\n    fastapi_apps = [{\"app\": app, \"url_prefix\": \"/my-plugin\", \"name\": \"My Plugin\"}]\n    react_apps = [\n        {\n            \"name\": \"My Plugin\",\n            \"bundle_url\": \"/my-plugin/my-app.js\",\n            \"destination\": \"nav\",\n            \"category\": \"browse\",\n            \"url_route\": \"my-plugin\",\n        }\n    ]\n```\n\nThe same bundle can be registered to multiple destinations by adding multiple entries — each needs a unique `url_route`:\n\n```python\nreact_apps = [\n    {\"name\": \"My Widget\", \"bundle_url\": \"/my-plugin/widget.js\", \"destination\": \"nav\",  \"url_route\": \"my-widget-nav\"},\n    {\"name\": \"My Widget\", \"bundle_url\": \"/my-plugin/widget.js\", \"destination\": \"dag\",  \"url_route\": \"my-widget-dag\"},\n]\n```\n\n> React app integration is experimental in Airflow 3.1. Interfaces may change in future releases.\n\n---\n\n## Step 7: Environment variables and deployment\n\nNever hardcode credentials:\n\n```python\nAIRFLOW_HOST = os.environ.get(\"MYPLUGIN_HOST\",     \"http://localhost:8080\")\nAIRFLOW_USER = os.environ.get(\"MYPLUGIN_USERNAME\", \"admin\")\nAIRFLOW_PASS = os.environ.get(\"MYPLUGIN_PASSWORD\", \"admin\")\n```\n\n**Local Astro CLI:**\n```\n# .env\nMYPLUGIN_HOST=http://localhost:8080\nMYPLUGIN_USERNAME=admin\nMYPLUGIN_PASSWORD=admin\n```\n\n```bash\nastro dev restart              # required after any Python plugin change\n\n# Check logs by component (Astro CLI):\nastro dev logs --api-server    # FastAPI apps, external_views — plugin import errors show here\nastro dev logs --scheduler     # macros, timetables, listeners, operator links\nastro dev logs --dag-processor # DAG parsing errors\n\n# Non-Astro:\nairflow plugins                # CLI — lists all loaded plugins\n```\n\n**Production Astronomer:**\n```bash\nastro deployment variable create --deployment-id <id> MYPLUGIN_HOST=https://airflow.example.com\n```\n\n**Auto-reload during development** (skips lazy loading):\n```\nAIRFLOW__CORE__LAZY_LOAD_PLUGINS=False\n```\n\n**Cache busting for static files** after deploy:\n```html\n<script src=\"static/app.js?v=20240315-1\"></script>\n```\n\n**Verify the plugin loaded**: open **Admin > Plugins** in the Airflow UI.\n\n**OpenAPI docs** are auto-generated for FastAPI plugins:\n- Swagger UI: `{AIRFLOW_HOST}/{url_prefix}/docs`\n- OpenAPI JSON: `{AIRFLOW_HOST}/{url_prefix}/openapi.json`\n\n---\n\n## Common pitfalls\n\n| Problem | Cause | Fix |\n|---------|-------|-----|\n| Nav link goes to 404 | Leading `/` in `href` | `\"my-plugin/ui\"` not `\"/my-plugin/ui\"` |\n| Nav icon not showing | Missing `/` in `icon` | `icon` takes an absolute path: `\"/my-plugin/static/icon.svg\"` |\n| Event loop freezes under load | Sync SDK called directly in `async def` | Wrap with `asyncio.to_thread()` |\n| 401 errors after 1 hour | JWT expires with no refresh | Use the 5-minute pre-expiry refresh pattern |\n| `StaticFiles` raises on startup | Directory missing | Create `assets/` and `static/` before starting |\n| Plugin not showing up | Python file changed without restart | `astro dev restart` |\n| Endpoints accessible without login | FastAPI apps are not auto-authenticated | Add FastAPI security (e.g. OAuth2, API key) if endpoints must be private |\n| Middleware affecting wrong routes | Middleware applies to all API traffic | Filter by `request.url.path` inside `dispatch()` |\n| JS `fetch()` breaks on Astro | Absolute path in `fetch()` | Always use relative paths: `fetch('api/dags')` |\n\n---\n\n## References\n\n- [Airflow plugins documentation](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/plugins.html)\n- [Airflow REST API reference](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html) — full endpoint list with SDK class/method names\n- [Astronomer: Using Airflow plugins](https://www.astronomer.io/docs/learn/using-airflow-plugins)\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}