dependabot-nuget 0.342.2 → 0.343.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60fbe0fbaa5bb2494d76a9cbe53912c79557910c13a5c2672721ca7665696995
4
- data.tar.gz: 027bc2de484a8724567e9901a88f3dac47acba9aca76fa1edec8a521a5ed1078
3
+ metadata.gz: b0a5be5cf920a9c9314b1377a657101d176b366b50cc385a9271056c55302a59
4
+ data.tar.gz: 35f2e1f95b349a6044a955c633a69bafa1a887859fe7324b77c6c5a94621dcf5
5
5
  SHA512:
6
- metadata.gz: 58150b153196abc1033d83ed24852e66bb8579f48bff844fdd867036fea12280cc53a7038d7f918189d741aabf1e2bfb628b41e1da86cc065b4ade0f68492e3e
7
- data.tar.gz: d6509ec9845d2540cdf3823b94587dd386adc72ddbcaaa12670bfa9a9624bdb9dbd7b5b7ae0fe176a98b9d140f818c6c776e3bd3125d4fe0f37726577853fc9a
6
+ metadata.gz: 121232d229b12c58087f63704e5e3e3ccee8e3e1b60f13e62645043c7607499d1042bd60bb2a0b0298e981c3b3bd9c8a0c0c2f2bec2ed49287024d6404b905ad
7
+ data.tar.gz: f619759742611bc9ea752fd5edbab1c647448ed0dfa7ef35ae37d7bf0d6e52548ad8f4fcc3c2489c3288c0833d03c3a871a68e3b500aad8ad11860a68b46f6fd
@@ -38,7 +38,7 @@ public abstract record JobErrorBase : MessageBase
38
38
  case BadRequirementException badRequirement:
39
39
  return new BadRequirement(badRequirement.Message);
40
40
  case BadResponseException badResponse:
41
- return new PrivateSourceBadResponse([badResponse.Uri]);
41
+ return new PrivateSourceBadResponse([badResponse.Uri], badResponse.Message);
42
42
  case DependencyNotFoundException dependencyNotFound:
43
43
  return new DependencyNotFound(string.Join(", ", dependencyNotFound.Dependencies));
44
44
  case HttpRequestException httpRequest:
@@ -48,7 +48,7 @@ public abstract record JobErrorBase : MessageBase
48
48
  ioException.HttpRequestError == HttpRequestError.ResponseEnded)
49
49
  {
50
50
  // server hung up on us
51
- return new PrivateSourceBadResponse(NuGetContext.GetPackageSourceUrls(currentDirectory));
51
+ return new PrivateSourceBadResponse(NuGetContext.GetPackageSourceUrls(currentDirectory), ioException.Message);
52
52
  }
53
53
 
54
54
  return new UnknownError(ex, jobId);
@@ -61,17 +61,17 @@ public abstract record JobErrorBase : MessageBase
61
61
  return new PrivateSourceAuthenticationFailure(NuGetContext.GetPackageSourceUrls(currentDirectory));
62
62
  case HttpStatusCode.TooManyRequests:
63
63
  case HttpStatusCode.ServiceUnavailable:
64
- return new PrivateSourceBadResponse(NuGetContext.GetPackageSourceUrls(currentDirectory));
64
+ return new PrivateSourceBadResponse(NuGetContext.GetPackageSourceUrls(currentDirectory), httpRequest.Message);
65
65
  default:
66
66
  if ((int)httpRequest.StatusCode / 100 == 5)
67
67
  {
68
- return new PrivateSourceBadResponse(NuGetContext.GetPackageSourceUrls(currentDirectory));
68
+ return new PrivateSourceBadResponse(NuGetContext.GetPackageSourceUrls(currentDirectory), httpRequest.Message);
69
69
  }
70
70
 
71
71
  return new UnknownError(ex, jobId);
72
72
  }
73
73
  case InvalidDataException invalidData when invalidData.Message == "Central Directory corrupt.":
74
- return new PrivateSourceBadResponse(NuGetContext.GetPackageSourceUrls(currentDirectory));
74
+ return new PrivateSourceBadResponse(NuGetContext.GetPackageSourceUrls(currentDirectory), invalidData.Message);
75
75
  case InvalidProjectFileException invalidProjectFile:
76
76
  return new DependencyFileNotParseable(invalidProjectFile.ProjectFile);
77
77
  case MissingFileException missingFile:
@@ -1,10 +1,25 @@
1
+ using System.Text.Json.Serialization;
2
+
1
3
  namespace NuGetUpdater.Core.Run.ApiModel;
2
4
 
3
5
  public record PrivateSourceBadResponse : JobErrorBase
4
6
  {
5
- public PrivateSourceBadResponse(string[] urls)
7
+ [JsonIgnore]
8
+ public string Message { get; }
9
+
10
+ public PrivateSourceBadResponse(string[] urls, string message)
6
11
  : base("private_source_bad_response")
7
12
  {
8
13
  Details["source"] = $"({string.Join("|", urls)})";
14
+ Message = message;
15
+ }
16
+
17
+ public override string GetReport()
18
+ {
19
+ var report = base.GetReport();
20
+
21
+ // this extra info isn't part of the reported shape but is useful to have in the log
22
+ var fullReport = string.Concat(report, "\n", $"- message: {Message}");
23
+ return fullReport;
9
24
  }
10
25
  }
@@ -1,8 +1,12 @@
1
1
  using System.Collections.Immutable;
2
+ using System.Text.Json.Serialization;
2
3
 
3
4
  namespace NuGetUpdater.Core.Run.ApiModel;
4
5
 
5
6
  public record PullRequest
6
7
  {
8
+ [JsonPropertyName("pr-number")]
9
+ public int? PrNumber { get; init; } = null;
10
+ [JsonPropertyName("dependencies")]
7
11
  public ImmutableArray<PullRequestDependency> Dependencies { get; init; } = [];
8
12
  }
@@ -1,4 +1,4 @@
1
- using System.Collections.Immutable;
1
+ using System.Collections.Immutable;
2
2
  using System.Text.Json;
3
3
  using System.Text.Json.Serialization;
4
4
 
@@ -10,16 +10,36 @@ public class PullRequestConverter : JsonConverter<PullRequest>
10
10
  {
11
11
  public override PullRequest? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
12
12
  {
13
- if (reader.TokenType != JsonTokenType.StartArray)
13
+ PullRequest? result;
14
+ switch (reader.TokenType)
14
15
  {
15
- throw new JsonException("expected array of pull request dependencies");
16
+ case JsonTokenType.StartArray:
17
+ // old format, array of arrays of dependencies
18
+ var dependencies = JsonSerializer.Deserialize<ImmutableArray<PullRequestDependency>>(ref reader, options);
19
+ result = new PullRequest()
20
+ {
21
+ Dependencies = dependencies
22
+ };
23
+ break;
24
+ case JsonTokenType.StartObject:
25
+ // new format, direct object
26
+ // use the same deserializer options but exclude this special converter
27
+ var optionsWithoutThisCustomConverter = new JsonSerializerOptions(options);
28
+ for (int i = optionsWithoutThisCustomConverter.Converters.Count - 1; i >= 0; i--)
29
+ {
30
+ if (optionsWithoutThisCustomConverter.Converters[i].GetType() == typeof(PullRequestConverter))
31
+ {
32
+ optionsWithoutThisCustomConverter.Converters.RemoveAt(i);
33
+ }
34
+ }
35
+
36
+ result = JsonSerializer.Deserialize<PullRequest>(ref reader, optionsWithoutThisCustomConverter);
37
+ break;
38
+ default:
39
+ throw new JsonException("expected pull request object or array of pull request dependencies");
16
40
  }
17
41
 
18
- var dependencies = JsonSerializer.Deserialize<ImmutableArray<PullRequestDependency>>(ref reader, options);
19
- return new PullRequest()
20
- {
21
- Dependencies = dependencies
22
- };
42
+ return result;
23
43
  }
24
44
 
25
45
  public override void Write(Utf8JsonWriter writer, PullRequest value, JsonSerializerOptions options)
@@ -293,7 +293,7 @@ public class VersionFinderTests : TestBase
293
293
  var error = JobErrorBase.ErrorFromException(exception, "TEST-JOB-ID", tempDir.DirectoryPath);
294
294
 
295
295
  // assert
296
- var expected = new PrivateSourceBadResponse([feedUrl]);
296
+ var expected = new PrivateSourceBadResponse([feedUrl], "unused");
297
297
  var expectedJson = JsonSerializer.Serialize(expected, RunWorker.SerializerOptions);
298
298
  var actualJson = JsonSerializer.Serialize(error, RunWorker.SerializerOptions);
299
299
  Assert.Equal(expectedJson, actualJson);
@@ -1124,7 +1124,7 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
1124
1124
  ],
1125
1125
  expectedResult: new()
1126
1126
  {
1127
- Error = new PrivateSourceBadResponse([$"{http.BaseUrl.TrimEnd('/')}/index.json"]),
1127
+ Error = new PrivateSourceBadResponse([$"{http.BaseUrl.TrimEnd('/')}/index.json"], "unused"),
1128
1128
  Path = "",
1129
1129
  Projects = [],
1130
1130
  }
@@ -1199,7 +1199,7 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
1199
1199
  ],
1200
1200
  expectedResult: new()
1201
1201
  {
1202
- Error = new PrivateSourceBadResponse([$"{http.BaseUrl.TrimEnd('/')}/index.json"]),
1202
+ Error = new PrivateSourceBadResponse([$"{http.BaseUrl.TrimEnd('/')}/index.json"], "unused"),
1203
1203
  Path = "",
1204
1204
  Projects = [],
1205
1205
  }
@@ -148,7 +148,7 @@ public class HttpApiHandlerTests
148
148
  yield return [new DependencyNotFound("unused"), "record_update_job_error"];
149
149
  yield return [new JobRepoNotFound("unused"), "record_update_job_error"];
150
150
  yield return [new PrivateSourceAuthenticationFailure(["unused"]), "record_update_job_error"];
151
- yield return [new PrivateSourceBadResponse(["unused"]), "record_update_job_error"];
151
+ yield return [new PrivateSourceBadResponse(["unused"], "unused"), "record_update_job_error"];
152
152
  yield return [new PrivateSourceTimedOut("unused"), "record_update_job_error"];
153
153
  yield return [new PullRequestExistsForLatestVersion("unused", "unused"), "record_update_job_error"];
154
154
  yield return [new PullRequestExistsForSecurityUpdate([]), "record_update_job_error"];
@@ -40,32 +40,39 @@ public class JobErrorBaseTests : TestBase
40
40
 
41
41
  public static IEnumerable<object[]> GenerateErrorFromExceptionTestData()
42
42
  {
43
+ // something elevated to a bad response
44
+ yield return
45
+ [
46
+ new BadResponseException("nope", "http://nuget.example.com/v3/index.json"),
47
+ new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"], "nope"),
48
+ ];
49
+
43
50
  // internal error from package feed
44
51
  yield return
45
52
  [
46
53
  new HttpRequestException("nope", null, HttpStatusCode.InternalServerError),
47
- new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"]),
54
+ new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"], "nope"),
48
55
  ];
49
56
 
50
57
  // inner exception turns into private_source_bad_response; 500
51
58
  yield return
52
59
  [
53
- new FatalProtocolException("nope", new HttpRequestException("nope", null, HttpStatusCode.InternalServerError)),
54
- new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"]),
60
+ new FatalProtocolException("nope", new HttpRequestException("inner nope", null, HttpStatusCode.InternalServerError)),
61
+ new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"], "inner nope"),
55
62
  ];
56
63
 
57
64
  // inner exception turns into private_source_bad_response; ResponseEnded
58
65
  yield return
59
66
  [
60
- new FatalProtocolException("nope", new HttpRequestException("nope", new HttpIOException(HttpRequestError.ResponseEnded))),
61
- new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"]),
67
+ new FatalProtocolException("nope", new HttpRequestException("inner nope", new HttpIOException(HttpRequestError.ResponseEnded))),
68
+ new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"], "inner nope"),
62
69
  ];
63
70
 
64
71
  // service returned corrupt package
65
72
  yield return
66
73
  [
67
74
  new InvalidDataException("Central Directory corrupt."),
68
- new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"]),
75
+ new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"], "Central Directory corrupt."),
69
76
  ];
70
77
 
71
78
  // top-level exception turns into private_source_authentication_failure
@@ -152,11 +152,12 @@ public class MessageReportTests
152
152
  yield return
153
153
  [
154
154
  // message
155
- new PrivateSourceBadResponse(["url1", "url2"]),
155
+ new PrivateSourceBadResponse(["url1", "url2"], "some extra info"),
156
156
  // expected
157
157
  """
158
158
  Error type: private_source_bad_response
159
159
  - source: (url1|url2)
160
+ - message: some extra info
160
161
  """
161
162
  ];
162
163
 
@@ -407,7 +407,7 @@ public class SerializationTests : TestBase
407
407
  }
408
408
 
409
409
  [Fact]
410
- public void DeserializeExistingPullRequests()
410
+ public void DeserializeExistingPullRequestsOldFormat()
411
411
  {
412
412
  var jsonWrapperJson = """
413
413
  {
@@ -429,6 +429,41 @@ public class SerializationTests : TestBase
429
429
  """;
430
430
  var jobWrapper = RunWorker.Deserialize(jsonWrapperJson)!;
431
431
  Assert.Single(jobWrapper.Job.ExistingPullRequests);
432
+ Assert.Null(jobWrapper.Job.ExistingPullRequests[0].PrNumber);
433
+ Assert.Single(jobWrapper.Job.ExistingPullRequests[0].Dependencies);
434
+ Assert.Equal("Some.Package", jobWrapper.Job.ExistingPullRequests[0].Dependencies[0].DependencyName);
435
+ Assert.Equal(NuGetVersion.Parse("1.2.3"), jobWrapper.Job.ExistingPullRequests[0].Dependencies[0].DependencyVersion);
436
+ Assert.False(jobWrapper.Job.ExistingPullRequests[0].Dependencies[0].DependencyRemoved);
437
+ Assert.Null(jobWrapper.Job.ExistingPullRequests[0].Dependencies[0].Directory);
438
+ }
439
+
440
+ [Fact]
441
+ public void DeserializeExistingPullRequestsNewFormat()
442
+ {
443
+ var jsonWrapperJson = """
444
+ {
445
+ "job": {
446
+ "source": {
447
+ "provider": "github",
448
+ "repo": "some/repo"
449
+ },
450
+ "existing-pull-requests": [
451
+ {
452
+ "pr-number": 123,
453
+ "dependencies": [
454
+ {
455
+ "dependency-name": "Some.Package",
456
+ "dependency-version": "1.2.3"
457
+ }
458
+ ]
459
+ }
460
+ ]
461
+ }
462
+ }
463
+ """;
464
+ var jobWrapper = RunWorker.Deserialize(jsonWrapperJson)!;
465
+ Assert.Single(jobWrapper.Job.ExistingPullRequests);
466
+ Assert.Equal(123, jobWrapper.Job.ExistingPullRequests[0].PrNumber);
432
467
  Assert.Single(jobWrapper.Job.ExistingPullRequests[0].Dependencies);
433
468
  Assert.Equal("Some.Package", jobWrapper.Job.ExistingPullRequests[0].Dependencies[0].DependencyName);
434
469
  Assert.Equal(NuGetVersion.Parse("1.2.3"), jobWrapper.Job.ExistingPullRequests[0].Dependencies[0].DependencyVersion);
@@ -766,7 +801,7 @@ public class SerializationTests : TestBase
766
801
 
767
802
  yield return
768
803
  [
769
- new PrivateSourceBadResponse(["url1", "url2"]),
804
+ new PrivateSourceBadResponse(["url1", "url2"], "unused"),
770
805
  """
771
806
  {"data":{"error-type":"private_source_bad_response","error-details":{"source":"(url1|url2)"}}}
772
807
  """
@@ -452,7 +452,7 @@ public class MSBuildHelperTests : TestBase
452
452
  // output
453
453
  "Response status code does not indicate success: 500 (Internal Server Error).",
454
454
  // expectedError
455
- new PrivateSourceBadResponse(["http://localhost/test-feed"]),
455
+ new PrivateSourceBadResponse(["http://localhost/test-feed"], "unused"),
456
456
  ];
457
457
 
458
458
  yield return
@@ -460,7 +460,7 @@ public class MSBuildHelperTests : TestBase
460
460
  // output
461
461
  "The response ended prematurely. (ResponseEnded)",
462
462
  // expectedError
463
- new PrivateSourceBadResponse(["http://localhost/test-feed"]),
463
+ new PrivateSourceBadResponse(["http://localhost/test-feed"], "unused"),
464
464
  ];
465
465
 
466
466
  yield return
@@ -468,7 +468,7 @@ public class MSBuildHelperTests : TestBase
468
468
  // output
469
469
  "The file is not a valid nupkg.",
470
470
  // expectedError
471
- new PrivateSourceBadResponse(["http://localhost/test-feed"]),
471
+ new PrivateSourceBadResponse(["http://localhost/test-feed"], "unused"),
472
472
  ];
473
473
 
474
474
  yield return
@@ -476,7 +476,7 @@ public class MSBuildHelperTests : TestBase
476
476
  // output
477
477
  "The content at 'http://localhost/test-feed/Packages(Id='Some.Package',Version='1.2.3')' is not valid XML.",
478
478
  // expectedError
479
- new PrivateSourceBadResponse(["http://localhost/test-feed"]),
479
+ new PrivateSourceBadResponse(["http://localhost/test-feed"], "unused"),
480
480
  ];
481
481
 
482
482
  yield return
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.342.2
4
+ version: 0.343.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.342.2
18
+ version: 0.343.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.342.2
25
+ version: 0.343.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -551,7 +551,7 @@ licenses:
551
551
  - MIT
552
552
  metadata:
553
553
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
554
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.342.2
554
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.343.0
555
555
  rdoc_options: []
556
556
  require_paths:
557
557
  - lib