mirror of
https://github.com/actions/runner.git
synced 2025-12-11 21:06:55 +00:00
Increase error body max length before truncation (#3762)
This commit is contained in:
@@ -253,11 +253,12 @@ namespace GitHub.Actions.RunService.WebApi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string Truncate(string errorBody)
|
internal static string Truncate(string errorBody)
|
||||||
{
|
{
|
||||||
if (errorBody.Length > 100)
|
const int maxLength = 200;
|
||||||
|
if (errorBody.Length > maxLength)
|
||||||
{
|
{
|
||||||
return errorBody.Substring(0, 100) + "[truncated]";
|
return errorBody.Substring(0, maxLength) + "[truncated]";
|
||||||
}
|
}
|
||||||
|
|
||||||
return errorBody;
|
return errorBody;
|
||||||
|
|||||||
20
src/Test/L0/Sdk/RSWebApi/RunServiceHttpClientL0.cs
Normal file
20
src/Test/L0/Sdk/RSWebApi/RunServiceHttpClientL0.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using GitHub.Actions.RunService.WebApi;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace GitHub.Actions.RunService.WebApi.Tests;
|
||||||
|
|
||||||
|
public sealed class RunServiceHttpClientL0
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Truncate()
|
||||||
|
{
|
||||||
|
TestTruncate(string.Empty.PadLeft(199, 'a'), string.Empty.PadLeft(199, 'a'));
|
||||||
|
TestTruncate(string.Empty.PadLeft(200, 'a'), string.Empty.PadLeft(200, 'a'));
|
||||||
|
TestTruncate(string.Empty.PadLeft(201, 'a'), string.Empty.PadLeft(200, 'a') + "[truncated]");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestTruncate(string errorBody, string expected)
|
||||||
|
{
|
||||||
|
Assert.Equal(expected, RunServiceHttpClient.Truncate(errorBody));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user