{"record":{"id":"ec0ca20f92c8624f","repo":"pulumi/pulumi","slug":"plain-resource-method-tok-incorrectly-returned","errorCode":null,"errorMessage":"Plain resource method '{tok}' incorrectly returned {problem}. This is an error in the provider, please report this to the provider developer.","messagePattern":"Plain resource method '(.+?)' incorrectly returned (.+?)\\. This is an error in the provider, please report this to the provider developer\\.","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"pkg/codegen/python/utilities.py","lineNumber":271,"sourceCode":"    typ: typing.Optional[type] = None,\n) -> typing.Any:\n    \"\"\"\n    Wraps pulumi.runtime.plain to force the output and return it plainly.\n    \"\"\"\n\n    output = pulumi.runtime.call(tok, props, res, typ)\n\n    # Ingoring deps silently. They are typically non-empty, r.f() calls include r as a dependency.\n    result, known, secret, _ = _sync_await(asyncio.create_task(_await_output(output)))\n\n    problem = None\n    if not known:\n        problem = ' an unknown value'\n    elif secret:\n        problem = ' a secret value'\n\n    if problem:\n        raise AssertionError(\n            f\"Plain resource method '{tok}' incorrectly returned {problem}. \"\n            + \"This is an error in the provider, please report this to the provider developer.\"\n        )\n\n    return result\n\n\nasync def _await_output(o: pulumi.Output[typing.Any]) -> typing.Tuple[object, bool, bool, set]:\n    return (\n        await o._future,\n        await o._is_known,\n        await o._is_secret,\n        await o._resources,\n    )\n\n\n# This is included to provide an upgrade path for users who are using a version\n# of the Pulumi SDK (<3.121.0) that does not include the `deprecated` decorator.","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/codegen/python/utilities.py#L253-L289","documentation":"Plain (non-output) resource method call results are checked for property-value problems: if the provider returned an unknown or secret value where the calling program expected a plain value, an AssertionError is raised telling the user the provider misbehaved and to report it. This is a runtime integrity check for outputs of `call` operations (resource methods) on plain resources.","triggerScenarios":"Calling a resource method (invoke-style method on a resource instance) whose provider implementation returns an Output that is Unknown (depends on an unknown preview value) or marked Secret, while the caller's type context requires a plain, known value.","commonSituations":"A provider bug where a method implementation wraps its result in pulumi.Output.secret or returns an unknown during preview; using a method on a resource whose inputs are still unknown at preview time; provider SDK misusing the call machinery.","solutions":["Report the bug to the provider developer (as the message instructs) with the method token and a repro","Work around by avoiding the method call during preview (gate it so it only runs with known inputs)","Pin/downgrade to a provider version where the method returns plain values","In application code, unwrap defensively — but note the real fix is in the provider"],"exampleFix":"# before (provider implementation)\ndef method(self, args):\n    return Output.secret(compute(args))  # wrongly secret\n# after\ndef method(self, args):\n    return compute(args)  # plain result","handlingStrategy":"try-catch","validationCode":"# Prefer checking known-ness before relying on a method result in preview:\nif pulumi.runtime.is_dry_run():\n    # avoid calling plain resource methods whose inputs may be unknown\n    ...","typeGuard":null,"tryCatchPattern":"try:\n    result = resource.some_method(args)\nexcept AssertionError as e:\n    if 'Plain resource method' in str(e):\n        # provider bug: report upstream; pin provider version or skip in preview\n        ...","preventionTips":["Keep provider plugins up to date; report offending methods to the provider maintainer","Avoid calling resource methods on resources with unknown/preview inputs","Pin to provider versions where the method returns plain values","Test provider methods in preview mode before production use"],"tags":["python","providers","outputs","runtime"],"backgroundTag":"provider-returned-secret","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}