opensafely-core / job-runner

A client for running jobs in an OpenSAFELY secure environment, requested via job-server (q.v.)
Other
3 stars 5 forks source link

Give useful error message for invalid `run` commands #304

Open HelenCEBM opened 2 years ago

HelenCEBM commented 2 years ago

This may be slightly related to the problem described in #233.

A user was trying to create a python action and ended up with an unhelpful error message that maybe we can improve...

They made an error in the project.yaml and came up with: run: python:action/my_code.py instead of run: python:latest python action/my_code.py

This produced non-zero exit status 1 which is impossible to interpret.

Can we make a more helpful error like invalid run command 'python:action/my_code.py'. Make sure you have specified the language to run in the format '<coding language>:latest <coding language> <action> or similar?

evansd commented 2 years ago

I think we could solve this with some basic validation of the version part of the <image>:<version> specifier. Possibly we can be quite strict here and accept only latest, vX, vX.Y and vX.Y.Z. At the very least we can reject anything with slashes in (which is what's causing Docker to throw an error).

The tricky bit I think will be wording the error message in a way that makes it helpful.

HelenCEBM commented 2 years ago

I think if the error message can (a) point out that the problem is with project.yaml and (b) which line is at fault, that would be a good start and much more helpful than the current error..