Skip to content

Commit dd239b8

Browse files
committed
Respond with 404 if job doesn't have a repository
We have some jobs which doesn't have any repository in our DB. This is a quick fix which returns 404 for such a request instead of raising an error
1 parent 21485d8 commit dd239b8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/travis/api/app/endpoint/jobs.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ class Jobs < Endpoint
1212
end
1313

1414
get '/:id' do
15-
respond_with service(:find_job, params)
15+
job = service(:find_job, params).run
16+
if job && job.repository
17+
respond_with job
18+
else
19+
json = { error: { message: "The job(#{params[:id]}) couldn't be found" } }
20+
status 404
21+
respond_with json
22+
end
1623
end
1724

1825
post '/:id/cancel' do

0 commit comments

Comments
 (0)