Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python codegen doesn't support non-object function return types #15738

Open
thomas11 opened this issue Mar 20, 2024 · 1 comment
Open

Python codegen doesn't support non-object function return types #15738

thomas11 opened this issue Mar 20, 2024 · 1 comment
Labels
area/codegen SDK-gen, program-gen, convert kind/bug Some behavior is incorrect or out of spec language/python

Comments

@thomas11
Copy link
Contributor

From gen.go:

	if fun.ReturnType != nil {
		if objectType, ok := fun.ReturnType.(*schema.ObjectType); ok {
			returnType = objectType
		} else {
			// TODO: remove when we add support for generalized return type for python
			return "", fmt.Errorf("python sdk-gen doesn't support non-Object return types for function %s", fun.Token)
		}
	}

This prevents providers from supporting invokes with non-object return types. Even worse, developers might not realize this until they've already spent time on it because one can add such invokes to the schema without issue.

@thomas11 thomas11 added area/codegen SDK-gen, program-gen, convert needs-triage Needs attention from the triage team python Pull requests that update Python code labels Mar 20, 2024
@mikhailshilkov
Copy link
Member

Linking the original PR that introduced the error above: #11418

@justinvp justinvp added language/python kind/bug Some behavior is incorrect or out of spec and removed python Pull requests that update Python code needs-triage Needs attention from the triage team labels Mar 22, 2024
thomas11 added a commit to pulumi/pulumi-azure-native that referenced this issue Apr 10, 2024
Resolves #3147

If we're generating response properties and the resolved schema has no
properties but is a primitive/array output, we include it as a special
property so invokes can be generated.

Ideally we'd just represent the response as a primitive type without the
wrapping magic property, using `FunctionSpec.ReturnType`, but
pulumi/pulumi#15738 and pulumi/pulumi#15739 prevent this.
    
Unfortunately, this change required adding a third boolean to
`genProperties` to limit this new case to function responses only. Happy
to incorporate suggestions to model this better.

This is a simple program that demonstrates one of the new invokes.
```ts
import * as app from "@pulumi/azure-native/app";
const id = app.getCustomDomainVerificationIdOutput();
export const customDomainVerificationId = id;
export const customDomainVerificationIdValue = id.value;
```

Output:
```
  + customDomainVerificationId     : {
      + value: "B11..."
    }
  + customDomainVerificationIdValue: "B11..."
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen SDK-gen, program-gen, convert kind/bug Some behavior is incorrect or out of spec language/python
Projects
None yet
Development

No branches or pull requests

3 participants