{"record":{"id":"77e409fa2d669f2b","repo":"pulumi/pulumi","slug":"cannot-read-resource-whose-options-are-lacking-an-77e409","errorCode":null,"errorMessage":"Cannot read resource whose options are lacking an ID value","messagePattern":"Cannot read resource whose options are lacking an ID value","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/python/lib/pulumi/runtime/resource.py","lineNumber":782,"sourceCode":"    core sdk (i.e. Resource.__init__) and then skip that caller type if it is a Resource or ComponentResource.\n\n    This is used to compute the source position of the user code that instantiated a resource.\n    \"\"\"\n\n    return None if len(stack.frames) < 1 else stack.frames[0].pc\n\n\ndef read_resource(\n    res: \"CustomResource\",\n    ty: str,\n    name: str,\n    props: \"Inputs\",\n    opts: \"ResourceOptions\",\n    typ: Optional[type] = None,\n    package_ref: Optional[Awaitable[Optional[str]]] = None,\n) -> None:\n    if opts.id is None:\n        raise Exception(\"Cannot read resource whose options are lacking an ID value\")\n\n    log.debug(f\"reading resource: ty={ty}, name={name}, id={_safe_str(opts.id)}\")\n    monitor = settings.get_monitor()\n\n    # If we have type information, we'll use its and the resource's type/name metadata\n    # for name translations rather than using the resource's translation methods.\n    transform_using_type_metadata = typ is not None\n\n    # Prepare the resource, similar to a RegisterResource. Reads are deliberately similar to RegisterResource except\n    # that we are populating the Resource object with properties associated with an already-live resource.\n    #\n    # Same as below, we initialize the URN property on the resource, which will always be resolved.\n    (resolve_urn, res.__dict__[\"urn\"]) = resource_output(res)\n\n    # Furthermore, since resources being Read must always be custom resources (enforced in the\n    # Resource constructor), we'll need to set up the ID field which will be populated at the end of\n    # the ReadResource call.\n    #","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/python/lib/pulumi/runtime/resource.py#L764-L800","documentation":"Raised by read_resource (the implementation behind CustomResource.get / read_resource_operation): reading an existing resource requires opts.id, because the engine must know which physical resource to fetch. Without an ID there is nothing to read.","triggerScenarios":"Calling MyResource.get(name, id=None) or CustomResource.get with ResourceOptions that lack an id, e.g. id coming from an Output/Optional that resolved to None.","commonSituations":"Using .get() on a resource whose id is derived from another resource's Output that was unknown/empty; copy-pasted get() calls without the id argument; reading a resource that was never created.","solutions":["Pass the existing physical ID: MyResource.get(\"name\", \"i-abc123\") or ResourceOptions(id=...).","If the id is an Output, use .get inside an apply or id=resource.id reference pattern instead of a resolved-None value.","If the resource is managed by this stack, construct it normally instead of calling .get()."],"exampleFix":"// before\nexisting = Instance.get(\"legacy\", id=None)\n\n// after\nexisting = Instance.get(\"legacy\", \"i-0abcd1234efgh5678\")","handlingStrategy":"validation","validationCode":"if opts.id is None:\n    raise ValueError(\"MyResource.get requires an explicit id\")","typeGuard":"def can_read(opts: ResourceOptions) -> bool:\n    return opts.id is not None","tryCatchPattern":"try:\n    existing = Instance.get(\"name\", id)\nexcept Exception as e:\n    if \"lacking an ID value\" in str(e):\n        raise ValueError(\"provide an explicit physical id to .get()\") from e","preventionTips":["Only call .get() with literal or definitely-known ids.","Never pass an Optional/Output id directly; resolve it first.","Use normal resource construction for stack-managed resources instead of .get()."],"tags":["python","pulumi","resource","read"],"backgroundTag":"missing-resource-id","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}