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

quoting of invalidation args #37

Open
automaticgiant opened this issue May 10, 2024 · 3 comments
Open

quoting of invalidation args #37

automaticgiant opened this issue May 10, 2024 · 3 comments

Comments

@automaticgiant
Copy link

automaticgiant commented May 10, 2024

i haven't dug in enough but i don't know that the exec/spawn call uses a shell, so when i do the invalidation with * in it, it complains. i think maybe you don't need to map/convert the paths to a quoted path, unless in some cases it would be running under a shell. what i can say is that i took that out of runner.ts so that it's just

  await getExecOutput('aws', [
    'cloudfront',
    'create-invalidation',
    '--distribution-id',
    distribution,
    '--paths',
    ...invalidationCandidates,
    ...cfargs,
  ])

and stopped getting the error:

/usr/local/bin/aws cloudfront create-invalidation --distribution-id E2Q69Q44OA19XZ --paths '/browser/*'

An error occurred (InvalidArgument) when calling the CreateInvalidation operation: Your request contains one or more invalid invalidation paths.

(this one has single quotes because i tried that first thinking the shell was trying to glob using the *, but now i think that aws just balked at there being quotes in it)

@automaticgiant
Copy link
Author

colleague double checked me:

So, it uses @actions/exec, https://github.com/actions/toolkit/blob/main/packages/exec/src/toolrunner.ts#L369 Is where spawn options are from
The async exec() function of ToolRunner in @actions/exec calls child_exec.spawn() with that and the getSpawnArgs as well https://github.com/actions/toolkit/blob/main/packages/exec/src/toolrunner.ts#L437
shell of options is defaulted to false:
shell | If true, runs command inside of a shell. Uses '/bin/sh' on Unix, and process.env.ComSpec on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell.
Default: false (no shell).
It looks like they use it directly out of the box, the only place to add your own options is on the getExecOutput call
https://github.com/actions/toolkit/blob/main/packages/exec/src/exec.ts#L44
but they are not set, so no shell wrapper

@automaticgiant
Copy link
Author

automaticgiant commented May 10, 2024

reproduced in a second use case by emptying bucket and redeploying

/usr/local/bin/aws cloudfront create-invalidation --distribution-id EXM8UQJAEYXRO --paths "/*"

all that said, i like your action and want to keep using it

since i can't run the tests (or maybe just don't know how) i won't bother with a pr since i figure you'd want test coverage, but happy to make the small change and fire one off if you like.

@automaticgiant
Copy link
Author

it doesn't look like this case is covered, but i'm not sure if i'm missing something
https://github.com/vladcosorg/action-s3-cloudfront-smart-deploy/actions/runs/8969816907/job/24632013892

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant