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

No error message for invalid binary #1812

Closed
jcampbell05 opened this issue Nov 17, 2022 · 2 comments
Closed

No error message for invalid binary #1812

jcampbell05 opened this issue Nov 17, 2022 · 2 comments

Comments

@jcampbell05
Copy link

jcampbell05 commented Nov 17, 2022

Environment

  • Platform: Docker Desktop For Mac
  • Docker Version: 20.10.21
  • Node.js Version: 16
  • Image Tag: node:16-slim, node:16

Expected Behavior

When downloading an invalid binary the container should throw an error.

Current Behavior

Certain "binaries" will just exit with a code 0. For example if we download the following binary from AWS using curl but forget to enable redirect follows. Then curl will just try to download the redirect response as a binary.

RUN curl https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie-arm64 -o /usr/local/bin/aws-lambda-rie
RUN chmod +x /usr/local/bin/aws-lambda-rie

But the binary is now 0 bytes. In some operating systems you will get an error indicating that the binary format is incorrect but for some reason in this container image we just get an exit code 0.

Possible Solution

I have no idea why this happens.

Steps to Reproduce

FROM node:16

RUN apt-get update && apt-get install -y curl
RUN curl https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie-arm64 -o /usr/local/bin/aws-lambda-rie
RUN chmod +x /usr/local/bin/aws-lambda-rie

CMD [" /usr/local/bin/aws-lambda-rie"]
ENTRYPOINT ["echo hello"]

This is the most minimal dockerfile which recreates it, if the binary is downloaded correctly with the -L flag then aws-lambda-rie should run continuously but if it hasn't been downloaded then it will exit immediately with a successful error code.

Additional Information

@nschonni
Copy link
Member

Sorry, this sounds like a stack overflow question rather than an issue for this repo. I don't see anything in this repo that would be tweaked to change a behaviour that you're expecting.
To rephrase, "I'm having an issue with a curl failure not giving me a message on a debian container". There is nothing about the Node specific image here

@nschonni nschonni closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2022
@yosifkit
Copy link
Contributor

Just a note that you should add -f to your curl invocation so that it exits with a failure on server error codes. That should hopefully prevent it from creating an empty file. Adding a checksum check or gpg verification would also help catch when the file is not what is expected. You should also do the download and chmod in the same RUN to prevent duplicates across image layers.

-f, --fail

(HTTP) Fail fast with no output at all on server errors. This is useful to enable scripts and users to better deal with failed attempts. In normal cases when an HTTP server fails to deliver a document, it returns an HTML document stating so (which often also describes why and more). This flag will prevent curl from outputting that and return error 22.

This method is not fail-safe and there are occasions where non-successful response codes will slip through, especially when authentication is involved (response codes 401 and 407).

- https://curl.se/docs/manpage.html#-f

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

3 participants