From 8857369fc34e22c5779dabdf69696068a9982e60 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 25 Sep 2017 07:05:50 +0200 Subject: [PATCH] Temporarily make fetch always try aggregate if content is nil (#155) We get a lot of 406 errors from travis-api V2 when trying to fetch log and I tracked it down to be a case when the remote log returns a nil content (the error is wrong and it should be 404, but that's another matter). This might happen when a log in the database has a NULL content, but aggregated_at is still for some reason set to a value. This commit is a hack in a way that if the diagnosis is right, we should fix it wherever the aggregated_at is wrongly set with content still being null. But it seems like the easiest solution at the moment. --- lib/travis/logs/services/fetch_log.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/travis/logs/services/fetch_log.rb b/lib/travis/logs/services/fetch_log.rb index bf1240fb..7f151556 100644 --- a/lib/travis/logs/services/fetch_log.rb +++ b/lib/travis/logs/services/fetch_log.rb @@ -44,12 +44,15 @@ def run(job_id: nil, id: nil, aggregate_on_demand: true) result = database.log_for_id(id) if id return nil if result.nil? - content = result[:content] + content = result[:content] + aggregated_at = result[:aggregated_at] - if aggregate_on_demand && result[:aggregated_at].nil? + if aggregate_on_demand && (aggregated_at.nil? || content.nil?) content = [ content, database.aggregated_on_demand(result[:id]) ].join('') + + content = nil if content.strip.empty? end removed_by_id = result.delete(:removed_by)