-
Notifications
You must be signed in to change notification settings - Fork 6
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
warning: most_recent is deprecated: This attribute has no purpose. Output needed? #651
Comments
Hi @eBeyond thanks for reporting the issue. This seems to be coming from a deprecation warning in the TF hcloud provider: https://github.com/hetznercloud/terraform-provider-hcloud/blob/cffad666d26a10f1d17fd1450599e14e3492f8da/internal/network/data_source.go#L70 Can you please check if you are using the data source and provide a program which reproduces the warning? |
Yes, it's the datasource it's coming from. I create a StackReference to my other stack and get the needed network. base_stack = StackReference("my/stack/change")
networks = base_stack.get_output("networks")
core_network = hcloud.get_network(id=networks["core"])
print(core_network.id) In the example the message is shown, when invoking the last line (print(...)) |
Did you mean to use See https://www.pulumi.com/docs/iac/concepts/inputs-outputs/apply/#accessing-single-outputs-with-apply for more details |
core_network = hcloud.get_network(id=networks["core"])
core_network.id.apply(lambda id: print(id)) would result into: error: Program failed with an unhandled exception:
Traceback (most recent call last):
File "<...>/core/__main__.py", line 13, in <module>
core_network.id.apply(lambda id: print(id))
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'apply' |
Ah, my bad, good point, thanks for trying it out! |
@eBeyond the example doesn't repro for me, can you please try upgrading to the latest hcloud provider version and add a self-contained repro of the problem? Are the stack references essential for the issue? Are all stacks using the latest hcloud version? import pulumi
import pulumi_hcloud as hcloud
def get_network(id_str: str) -> None:
net = hcloud.get_network(id=int(id_str))
print(net.id)
core_network = hcloud.Network(
"core",
name="core",
ip_range="10.0.0.0/8",
)
core_network.id.apply(get_network) |
import pulumi
import pulumi_hcloud as hcloud
core_network = hcloud.Network(
"core1",
name="core1",
ip_range="10.123.0.0/24",
)
net = hcloud.get_network(id=core_network.id)
pulumi.Output.all(network=net).apply(lambda args: print(args["network"].id)) This produces the following output: Type Name Plan Info
pulumi:pulumi:Stack core1-core1 1 warning; 3 messages
Diagnostics:
pulumi:pulumi:Stack (core1-core1):
/<...>/python3.13/site-packages/pulumi_hcloud/_utilities.py:313: UserWarning: This attribute has no purpose.
warnings.warn(message)
warning: most_recent is deprecated: This attribute has no purpose.
10433892
Resources:
2 unchanged The pulumi.Output.all(...).apply is a commonly used option to process values from multiple outputs. It seems that the conversion to a dict will also visit the "most_recent" field and that triggers the warning. |
Hi @eBeyond. From the example you listed, I think the warning is actually coming from the P.S. Your example doesn't type-check: $ pyright
/Users/iwahbe/Projects/pulumi/langs/python/__main__.py
/Users/iwahbe/Projects/pulumi/langs/python/__main__.py:10:29 - error: Argument of type "Output[str]" cannot be assigned to parameter "id" of type "int | None" in function "get_network"
Type "Output[str]" cannot be assigned to type "int | None"
"Output[str]" is incompatible with "int"
"Output[str]" is incompatible with "None" (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations I think what you want would look like this: import pulumi
import pulumi_hcloud as hcloud
core_network = hcloud.Network(
"core1",
name="core1",
ip_range="10.123.0.0/24",
)
net = hcloud.get_network_output(id=core_network.id.apply(int))
net.id.apply(print) |
Hi, """A Python Pulumi program"""
import pulumi
import pulumi_hcloud as hcloud
core_network = hcloud.Network(
"core1",
name="core1",
ip_range="10.123.0.0/24",
)
net = hcloud.get_network(id=core_network.id)
print(f"first print: {net.id}")
pulumi.Output.all(network=net).apply(lambda args: print(f"second print: {args["network"].id}")) If you comment out the first print. You'll get the warning. If you comment out the second print (the output.all thing), you won't get a warning. |
I opened pulumi/pulumi#17965 upstream. I believe that
The problem is not with import pulumi
import pulumi_hcloud as hcloud
core_network = hcloud.Network(
"core1",
name="core1",
ip_range="10.123.0.0/24",
)
async def do(core_network_id: str):
net = hcloud.get_network(id=int(core_network_id))
await net
core_network.id.apply(do) |
When running pulumi preview with some servers (using the latest release) I get these outputs:
It's not stopping anything, so it's not a bug. But I don't feel comfortable with that. Do we need this?
I wasn't using most_recent as an attribute. So I think that's something internal.
The text was updated successfully, but these errors were encountered: