diff --git a/endpoints/api/build.py b/endpoints/api/build.py index ae97571eb..ca7866f85 100644 --- a/endpoints/api/build.py +++ b/endpoints/api/build.py @@ -276,9 +276,12 @@ class RepositoryBuildList(RepositoryParamResource): if repo is None: raise NotFound() - build_name = (user_files.get_file_checksum(dockerfile_id) - if dockerfile_id - else hashlib.sha224(archive_url).hexdigest()[0:7]) + try: + build_name = (user_files.get_file_checksum(dockerfile_id) + if dockerfile_id + else hashlib.sha224(archive_url).hexdigest()[0:7]) + except IOError: + raise InvalidRequest('File %s could not be found or is invalid' % dockerfile_id) prepared = PreparedBuild() prepared.build_name = build_name