{"record":{"id":"d927b7aed5c473b2","repo":"iflytek/astron-agent","slug":"pg-sql-node-execution-error","errorCode":"PG_SQL_NODE_EXECUTION_ERROR","errorMessage":"PGSQL_URL environment variable is not set","messagePattern":"PGSQL_URL environment variable is not set","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/pgsql/pgsql_client.py","lineNumber":79,"sourceCode":"\n        :param config: Configuration object containing database connection parameters\n        \"\"\"\n        self.config = config\n\n    async def exec_dml(self, span: Span) -> Dict[str, Any]:\n        \"\"\"Execute Data Manipulation Language (DML) statement.\n\n        Sends a POST request to the PostgreSQL service with the configured\n        DML statement and returns the execution result.\n\n        :param span: Tracing span for monitoring and logging\n        :return: Dictionary containing the execution result and response data\n        :raises CustomException: If environment variable is not set or request fails\n        \"\"\"\n        # Validate that the PostgreSQL service URL is configured\n        url = self.config.url\n        if url is None:\n            raise CustomException(\n                CodeEnum.PG_SQL_NODE_EXECUTION_ERROR,\n                err_msg=\"PGSQL_URL environment variable is not set\",\n            )\n        # Prepare request payload and headers\n        payload = self.payload()\n        headers = {\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": f\"Bearer ${self.config.apiKey}\",\n            \"X-Consumer-Username\": self.config.appId,\n        }\n        # Add space_id to payload if provided\n        if self.config.spaceId:\n            payload[\"space_id\"] = self.config.spaceId\n        # Start tracing span for request monitoring\n        with span.start(\n            func_name=\"exec_dml_request\", add_source_function_name=True\n        ) as request_span:\n            # Log request details for tracing","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/pgsql/pgsql_client.py#L61-L97","documentation":"The PGSQL node client requires a PostgreSQL service URL to forward DML requests to. This error is thrown by `exec_dml` in pgsql_client.py when `self.config.url` is None, meaning the PGSQL_URL environment variable (or equivalent config) was never provided. The client refuses to proceed because it has no endpoint to send the SQL request to.","triggerScenarios":"Calling `PgsqlClient.exec_dml(...)` when the `PGSQL_URL` environment variable is unset, so the constructed config carries `url=None`.","commonSituations":"Deploying the workflow service without the PGSQL_URL env var in the container/manifest; docker-compose or Helm values missing the env entry; local dev run without a .env file; renaming the env var in a config refactor while old deployments still lack it.","solutions":["Set the PGSQL_URL environment variable for the workflow service (e.g. export PGSQL_URL=http://pgsql-proxy:8080) and restart the service.","Add PGSQL_URL to the deployment config (docker-compose env / Helm values / k8s secret) so every replica has it.","Verify at startup that PGSQL_URL is present (fail fast healthcheck) instead of discovering it at node execution time.","Check config loading code (dotenv, configmap mount) to confirm the variable is actually read into the Pgsql config."],"exampleFix":"// before (docker-compose.yml)\nservices:\n  workflow:\n    image: workflow:latest\n// after (docker-compose.yml)\nservices:\n  workflow:\n    image: workflow:latest\n    environment:\n      - PGSQL_URL=http://pgsql-service:8080","handlingStrategy":"validation","validationCode":"import os\nif not os.getenv(\"PGSQL_URL\"):\n    raise RuntimeError(\"PGSQL_URL must be set before executing PGSQL nodes\")","typeGuard":"def has_pgsql_url(config) -> bool:\n    return bool(getattr(config, \"url\", None))","tryCatchPattern":"try:\n    result = client.exec_dml(...)\nexcept CustomException as e:\n    if \"PGSQL_URL\" in str(e):\n        # surface config error to operator, skip node\n        ...\n    raise","preventionTips":["Add PGSQL_URL to your .env.example and CI/deploy checklists","Fail fast at service startup if PGSQL_URL is missing","Document the env var in the deployment (Helm values / compose) README"],"tags":["environment","configuration","postgresql","missing-config"],"backgroundTag":"missing-env-var","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}