Closed gsmet closed 4 months ago
I have a working patch... can't say it was easy...
We are seeing a similar issue but in our case it's not related to the upload-artifact
action, but to accessing run logs.
See https://github.com/graalvm/mandrel/issues/687
Main.java
with the following content:
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.kohsuke:github-api:1.319
import org.kohsuke.github.*; import org.kohsuke.github.function.InputStreamFunction;
import java.io.IOException; import java.io.UncheckedIOException; import java.io.BufferedReader; import java.io.InputStreamReader;
class Main {
private static String token;
private static String thisRepo;
private static String runId;
private static InputStreamFunction<String> getLogArchiveInputStreamFunction(String... filters) {
return (is) -> {
StringBuilder stringBuilder = new StringBuilder();
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(System.lineSeparator());
}
}
return stringBuilder.toString();
};
}
public static void main(String... args) {
thisRepo = args[0];
runId = args[1];
if (args.length > 2) {
token = args[2];
}
else {
token = System.getenv("GITHUB_TOKEN");
}
try {
final GitHub github = new GitHubBuilder().withOAuthToken(token).build();
final GHRepository workflowRepository = github.getRepository(thisRepo);
GHWorkflowRun workflowRun = workflowRepository.getWorkflowRun(Long.parseLong(runId));
PagedIterable<GHWorkflowJob> listJobs = workflowRun.listJobs();
listJobs.forEach(job -> {
try {
System.out.println(job.downloadLogs(getLogArchiveInputStreamFunction()));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
2.Run with:
jbang ./Main.java hub4j/github-api 8119280581 [your_gh_token]
@zakkak yeah, I checked the URLs and they are using the same infrastructure as upload-artifact@v4
for the logs, thus why we have the same issue.
GitHub published a new version of upload-artifact, v4: https://github.com/actions/upload-artifact . It is supposed to be a lot better, most notably faster and more flexible.
I tried to use it and unfortunately, we hit an issue:
I stumbled upon https://github.com/arduino/report-size-deltas/pull/83 which seems to indicate that we shouldn't send the
Authorization
header to the download URL. Unfortunately, my guess is that the Java HTTP Client is not flexible enough for that and is sending theAuthorization
header anyway. It's not possible to configure the redirect behavior at the request level either so that's a bit problematic.I'm not completely sure how to solve this (or even if my diagnostic is the correct one...).