docs icon indicating copy to clipboard operation
docs copied to clipboard

Enhance CLI messaging

Open toriancrane opened this issue 1 year ago • 0 comments

The current error message looks like the following:

Calling __str__ on an Output[T] is not supported. To get the value of an Output[T] as an Output[str] consider: 1. o.apply(lambda v: f"prefix{v}suffix") See https://pulumi.io/help/outputs for more details.

The lambda v: f"prefix{v}suffix part of this message is especially confusing because this error comes up in scenarios that do not involve any string concatenation or anything involving a prefix or suffix. Some recommendations for enhancements include:

  • Removing that example and just redirecting users to the docs to see multiple examples of how to get their desired value (this is also assuming that the docs have been updated to provide more clarity in this regard)
  • Providing a longer but still concise list of some of the more common use cases. Ex:
Calling __str__ on an Output[T] is not supported.
To get the value of an Output[T] as an Output[str]

consider:
    1. <Output[T]>.apply(lambda v: v)
    2. <Output[T]>.apply(lambda v: f"randomstring{v}restofstring")
    3. <Output[T]>.apply(lambda v: f"prefix-{v}-suffix")
    4. myVariable = <Output[T]>.apply(lambda v: f"{v}")
    5. myVariable = some.key.apply(lambda value: f"{value}")

See[ https://www.pulumi.com/docs/concepts/inputs-outputs](https://www.pulumi.com/docs/concepts/inputs-outputs) for more details on working with Outputs in Pulumi.

toriancrane avatar Jan 11 '24 17:01 toriancrane