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

hab pkg download file read is fragile #7040

Closed
markan opened this issue Oct 15, 2019 · 0 comments · Fixed by #7064
Closed

hab pkg download file read is fragile #7040

markan opened this issue Oct 15, 2019 · 0 comments · Fixed by #7064
Assignees
Labels
Type: Bug Issues that describe broken functionality

Comments

@markan
Copy link
Contributor

markan commented Oct 15, 2019

The hab pkg download command accepts a file of newline separated identifiers as input with the --file flag. The code to read this file is very sensitive to whitespace, and doesn't return terribly great errors. In particular, a trailing newline gives a very opaque error.

To fix this, we should filter out whitespace and skip blank lines before trying to parse the package idents.

When we fix this, I'd like to suggest one additional change.

It seems like going forward we're going to be treating those files as artifacts that we're maintaining (see #6902). While they are meant to be easily machine readable, it would be very useful to have a comment mechanism to allow inline annotations in the files themselves.
As a part of being more robust to spaces it would be a trivial extension to allow the '#' to act as a line comment. (as is done in many scripting languages (i.e. bash, powershell, ruby....)

In terms of cost, this would be one additional line of code, I suspect .split("#").nth(0) would be enough.

@markan markan added the C-bug label Oct 15, 2019
markan added a commit that referenced this issue Oct 18, 2019
As reported in #7040, the file reader for hab pkg download is fragile. Trailing whitespace gives an
unpleasant error, and there's no way to comment. This alters the file reader to ignore whitespace,
and adds '#' as a comment character, similar to the usage in many other interpreted languages.

Signed-off-by: Mark Anderson <mark@chef.io>
@markan markan self-assigned this Oct 18, 2019
markan added a commit that referenced this issue Oct 18, 2019
As reported in #7040, the file reader for hab pkg download is fragile. Trailing whitespace gives an
unpleasant error, and there's no way to comment. This alters the file reader to ignore whitespace,
and adds '#' as a comment character, similar to the usage in many other interpreted languages.

Signed-off-by: Mark Anderson <mark@chef.io>
markan added a commit that referenced this issue Oct 18, 2019
As reported in #7040, the file reader for hab pkg download is fragile. Trailing whitespace gives an
unpleasant error, and there's no way to comment. This alters the file reader to ignore whitespace,
and adds '#' as a comment character, similar to the usage in many other interpreted languages.

Signed-off-by: Mark Anderson <mark@chef.io>
markan added a commit that referenced this issue Oct 21, 2019
As reported in #7040, the file reader for hab pkg download is fragile. Trailing whitespace gives an
unpleasant error, and there's no way to comment. This alters the file reader to ignore whitespace,
and adds '#' as a comment character, similar to the usage in many other interpreted languages.

Signed-off-by: Mark Anderson <mark@chef.io>
@markan markan reopened this Oct 21, 2019
@krasnow krasnow closed this as completed Jan 29, 2020
@christophermaier christophermaier added Type: Bug Issues that describe broken functionality and removed C-bug labels Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issues that describe broken functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants