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

Allows empty links in YAML configuration file. #1087

Closed
wants to merge 1 commit into from

Conversation

tristan0x
Copy link

Fixed TypeError: 'NoneType' object is not iterable issue when service declares an empty list of links.
Fixes #1086

Signed-off-by: Tristan Carel tristan@cogniteev.com

Fixed `TypeError: 'NoneType' object is not iterable` issue when service declares an empty list of `links`.
@aanand
Copy link

aanand commented Mar 12, 2015

Thanks, but I'd rather not allow links to be None. It'd be better to throw a helpful error.

@tristan0x
Copy link
Author

Yet, this is valid YAML:

console:
   image: busybox:latest
   links:
   command: /bin/sleep 300

In that case, links are None. It is what the yaml library returns. But it still means empty list of links.

Do you expect compose to throw an helpful error for such config?

If you don't, here is a patch proposal!
I understand you prefer a clean model in compose.project.Project class, without stuff like None links. So what about fixing the YAML returned by compose.cli.command.Command.get_config member method by replacing None by [] for a bunch of keys:

  • links
  • external_links
  • ports
  • volumes
  • volumes_from
  • env_file

@tristan0x tristan0x closed this Apr 10, 2015
@ghost
Copy link

ghost commented Apr 21, 2015

@tristan0x: Why was this closed without merging?

I often run into this "NoneType is not iterable" problem when I forget to remove an empty YAML key, and your change seemed like a step in the right direction. If anything, I think your change should be expanded to the other YAML keys (as you suggest in your Mar 12 comment).

👍 for this pr

@tristan0x
Copy link
Author

@mgoelzer : This issue is part of something bigger which is configuration validation. Please see #129
Thank anyway for your support :)

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

Successfully merging this pull request may close these issues.

Cannot service with an empty list of links
2 participants