{"record":{"id":"23d12ad549a5fda3","repo":"anomalyco/sst","slug":"cannot-access-nodes-taskdefinition-in-dev-mode-23d12a","errorCode":null,"errorMessage":"Cannot access `nodes.taskDefinition` in dev mode.","messagePattern":"Cannot access `nodes\\.taskDefinition` in dev mode\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service.ts","lineNumber":2898,"sourceCode":"      get service() {\n        if (self.dev)\n          throw new VisibleError(\"Cannot access `nodes.service` in dev mode.\");\n        return self._service!;\n      },\n      /**\n       * The Amazon ECS Execution Role.\n       */\n      executionRole: this.executionRole,\n      /**\n       * The Amazon ECS Task Role.\n       */\n      taskRole: this.taskRole,\n      /**\n       * The Amazon ECS Task Definition.\n       */\n      get taskDefinition() {\n        if (self.dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.taskDefinition` in dev mode.\",\n          );\n        return self.taskDefinition!;\n      },\n      /**\n       * The Amazon Elastic Load Balancer.\n       */\n      get loadBalancer() {\n        if (self.dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.loadBalancer` in dev mode.\",\n          );\n        if (!self.loadBalancer)\n          throw new VisibleError(\n            \"Cannot access `nodes.loadBalancer` when no public ports are exposed.\",\n          );\n        return self.loadBalancer;\n      },","sourceCodeStart":2880,"sourceCodeEnd":2916,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service.ts#L2880-L2916","documentation":"The Service component's `nodes` getter exposes raw Pulumi resources it creates. In `sst dev` mode the Service runs as a live dev process against the cluster and the ECS Task Definition resource is never created, so accessing `nodes.taskDefinition` would return `undefined`. SST throws this VisibleError to fail fast instead of letting downstream code operate on a missing resource.","triggerScenarios":"Reading `service.nodes.taskDefinition` in an sst.config.ts while `sst dev` is running (i.e. `sst dev` with a Service component configured, or `dev.command` set so the component is in dev mode).","commonSituations":"Referencing `nodes.taskDefinition` to build an IAM policy, log group attachment, or custom ECS resource that unconditionally reads the property; the same sst.config.ts works on `sst deploy` but crashes under `sst dev` because dev mode is environment-dependent.","solutions":["Do not read `nodes.taskDefinition` when the app is in dev mode; gate the access with `$dev` (from `sst/dev`) so the code only runs on deploy.","If you need the resource only for deployment-time wiring, move that logic behind `if (!$dev) { ... }` and provide a dev-mode alternative.","Run `sst deploy` (not `sst dev`) for the workflow that requires the underlying Task Definition."],"exampleFix":"// before\nconst td = service.nodes.taskDefinition;\n\n// after\nimport { $dev } from \"sst/dev\";\nconst td = $dev ? undefined : service.nodes.taskDefinition;","handlingStrategy":"validation","validationCode":"import { $dev } from \"sst/dev\";\nif (!$dev) {\n  const td = service.nodes.taskDefinition; // safe on deploy\n}","typeGuard":"import { $dev } from \"sst/dev\";\nconst hasTaskDefinition = (): boolean => !$dev;","tryCatchPattern":"import { VisibleError } from \"sst/platform/src/components/error\"; // conceptual\ntry {\n  const td = service.nodes.taskDefinition;\n} catch (e) {\n  if (String(e).includes(\"in dev mode\")) {\n    // dev-mode fallback: skip task-definition wiring\n  } else throw e;\n}","preventionTips":["Never read `nodes.*` unconditionally in sst.config.ts; always consider dev mode.","Use `$dev` from `sst/dev` to branch deploy-only resource wiring.","Test configs under both `sst dev` and `sst deploy` before committing.","Prefer the component's public API/links over raw nodes when available."],"tags":["dev-mode","ecs","nodes","sst"],"backgroundTag":"resource-unavailable-in-dev-mode","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}