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 policy packs produce error when using verbose logging #350

Closed
pierskarsenbarg opened this issue May 17, 2024 · 2 comments
Closed
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team resolution/duplicate This issue is a duplicate of another issue

Comments

@pierskarsenbarg
Copy link
Member

What happened?

I have a basic pulumi program with a python policy: https://github.com/pierskarsenbarg/policy-pack-logging-bug

I published the pack to the Demo org in Pulumi cloud and added the above stack to a policy group.

When I run either a preview or an update with logging turned on (i.e. pulumi up --logtostderr --logflow -v=10 2> out.txt) I get the following error:

I0517 09:36:21.421334   92949 main.go:309] one or more errors while discovering plugins: 2 errors occurred:
    	* unmarshaling package.json /Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/policy-pack-logging/node_modules/resolve/test/resolver/false_main/package.json: json: cannot unmarshal bool into Go struct field packageJSON.main of type string
    	* unmarshaling package.json /Users/piers/go/src/github.com/pierskarsenbarg/scratchpad/policy-pack-logging/node_modules/resolve/test/resolver/invalid_main/package.json: json: cannot unmarshal array into Go struct field packageJSON.main of type string

    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/Users/piers/.pulumi/policies/demo/pulumi-analyzer-piers-policy-test-v0.0.2/venv/lib/python3.12/site-packages/pulumi/policy/__main__.py", line 61, in main
        runpy.run_path(program, run_name="__main__")
      File "<frozen runpy>", line 285, in run_path
      File "<frozen runpy>", line 254, in _get_code_from_file
    FileNotFoundError: [Errno 2] No such file or directory: '/Users/piers/.pulumi/policies/demo/pulumi-analyzer-piers-policy-test-v0.0.2/-v=10'

(it looks like the -v=10 is being added to the file path for the policy pack)

Example

See above

Output of pulumi about

CLI
Version      3.115.2
Go Version   go1.22.2
Go Compiler  gc

Plugins
KIND      NAME    VERSION
resource  aws     6.36.0
resource  awsx    2.10.0
resource  docker  4.5.3
resource  docker  3.6.1
language  nodejs  unknown

Host
OS       darwin
Version  14.4.1
Arch     arm64

This project is written in nodejs: executable='/Users/piers/.nvm/versions/node/v20.11.1/bin/node' version='v20.11.1'

Current Stack: demo/policy-pack-logging/dev

Found no resources associated with demo/dev

Found no pending operations associated with demo/dev

Backend
Name           pulumi.com
URL            https://app.pulumi.com/pierskarsenbarg
User           pierskarsenbarg
Organizations  pierskarsenbarg, karsenbarg, team-ce, gitlab-test-piers, demo
Token type     personal

Dependencies:
NAME            VERSION
@pulumi/aws     6.36.0
@pulumi/awsx    2.10.0
@pulumi/pulumi  3.116.1
@types/node     18.19.33
typescript      5.4.5

Pulumi locates its logs in /var/folders/x8/cdd9j87s607fwpy0q62mfmmw0000gn/T/ by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@pierskarsenbarg pierskarsenbarg added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels May 17, 2024
@pierskarsenbarg
Copy link
Member Author

The same process with a typescript policy doesn't have the same problem so looks like it's a python thing.

@pierskarsenbarg pierskarsenbarg added the resolution/duplicate This issue is a duplicate of another issue label May 17, 2024
@pierskarsenbarg
Copy link
Member Author

Closing as duplicate of pulumi/pulumi#11092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team resolution/duplicate This issue is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

1 participant