Closed edward2a closed 7 years ago
Can you provide your appspec.yml file?
The following file:
version: 0.0
os: linux
hooks:
BeforeInstall:
AfterInstall:
- location: scripts/test.sh
files:
- source: files/test.txt
destination: /tmp
permissions:
...
Causes the following:
BeforeInstall | July 25, 2017 9:51:22 AM UTC | July 25, 2017 9:51:22 AM UTC | less than one second | Failed | View Logs
Error CodeUnknownError Script Name Message undefined method `each' for nil:NilClass Log Tail
2017-07-28 08:30:40 ERROR [codedeploy-agent(30701)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: NoMethodError - undefined method `each' for nil:NilClass - /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb:58:in `block in parse_hooks'
Pull request merged.
Hi, just run across this issue when testing a templated appspec.yml.
Apparently there is a for-each loop parsing the deployment hooks and when a hook is empty (say, it is there for reference), it fails with: Error CodeUnknownError Message undefined method `each' for nil:NilClass
I assume there is no validation of 'hook is nil' or 'hook is array' and yaml syntax validation is not likely to alert on this as 'mykey: ' is valid (please correct me here if I'm wrong here).
You could argue that non-used stuff should not be there, but that will require processing in the template building process to remove null value keys and, personally, I believe it would be easier to validate 'hook is array' before trying to execute it.
Just a thought.