Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/lib/frontend/handlers/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Future<shelf.Response> packageScoreLogTxtHandler(
}
final log = await taskBackend.taskLog(package, version);
return shelf.Response(
log == null ? 404 : 200,
log == null || log.startsWith('no log -') ? 404 : 200,
body: log ?? 'no log',
headers: {
'content-type': 'text/plain;charset=UTF-8',
Expand Down
14 changes: 11 additions & 3 deletions app/lib/task/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ class TaskBackend {

/// Get log from task run of [package] and [version].
///
/// Returns `null`, if not available.
/// If log is unavailable, it returns some information about the internal state.
///
/// If log is unavailable it's usually because:
/// * package is not tracked for analysis,
Expand All @@ -973,13 +973,21 @@ class TaskBackend {
Future<String?> taskLog(String package, String version) async {
final data = await gzippedTaskResult(package, version, 'log.txt');
if (data == null) {
return null;
final status = await packageStatus(package);
if (status.runtimeVersion == null) {
return 'no log - `PackageState` entity missing';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike revealing our datastore schema internals in a public facing endpoint.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about - no tracking information?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better!

}
final v = status.versions[version];
if (v == null) {
return 'no log - version is not tracked';
}
return 'no log - current version status: ${v.status}';
}
try {
return utf8.decode(gzip.decode(data), allowMalformed: true);
} on FormatException catch (e, st) {
_log.shout('Task log for $package/$version is malformed', e, st);
return null;
return 'no log - `log.txt` contains malformed characters';
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/test/task/task_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void main() {

// Check that the log is missing.
final log1 = await taskBackend.taskLog('oxygen', '1.2.0');
expect(log1, isNull);
expect(log1, 'no log - version is not tracked');

// Check that the dartdoc is missing
final dartdoc1 = await taskBackend.dartdocFile(
Expand Down