Commit d5af07d
fix(cli): resolve prebuilt Java provider versions via repo1.maven.org (#285)
### Description
The Java integration tests (`provider-add`, `provider-list`,
`provider-upgrade`) have been intermittently failing, resolving a
prebuilt provider package version one or two below the expected maximum
(e.g. `0.2.55` → `0.2.53`/`0.2.54`).
#### Example Failed jobs
-
https://github.com/open-constructs/cdk-terrain/actions/runs/28284215519/job/83805855926?pr=284
-
https://github.com/open-constructs/cdk-terrain/actions/runs/28284215519/job/83805856150?pr=284
#### Cause
When adding a prebuilt Java provider, the resolver walks the npm
candidate versions highest-to-lowest and installs the first that exists
on Maven Central, using `JavaPackageManager.isNpmVersionAvailable` to
decide existence. That check queries the `search.maven.org/solrsearch`
index — a separate service from the artifact repository, and a flaky
one: under load it returns `HTTP 502` and can take ~90s to respond. A
failed search response reads as "version not found", so the resolver
drops to an older package.
#### Fix
This PR points the existence check at the artifact repository directly:
- **Probe `repo1.maven.org`**
([`package-manager.ts`](packages/@cdktn/cli-core/src/lib/dependencies/package-manager.ts)):
`JavaPackageManager.isNpmVersionAvailable` requests the artifact's
`.pom` directly
(`https://repo1.maven.org/maven2/<group>/<artifact>/<version>/<artifact>-<version>.pom`)
with a plain `fetch`, matching the shape of the other package managers'
probes — `200` means present, anything else means not available.
`repo1.maven.org` is the Fastly-fronted artifact CDN every Maven build
already relies on, so it is both the source of truth for "is this
artifact published" and reliably fast (~0.05s).
**Why a direct file check rather than the `central.sonatype.com` search
API:** the artifact CDN is the most reliable signal and the fastest,
with the fewest moving parts. The Sonatype Central search API is the
documented successor to `search.maven.org`, but it is still a search
index in front of the same artifacts; querying the artifact directly
depends only on the artifact itself.
### Checklist
- [x] I have updated the PR title to match [CDKTN's style
guide](https://github.com/open-constructs/cdk-terrain/blob/main/CONTRIBUTING.md#pull-requests-1)
- [x] I have run the linter on my code locally
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the
[documentation](https://github.com/open-constructs/cdk-terrain-docs/tree/main/content)
if applicable
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works if applicable
- [x] New and existing unit tests pass locally with my changes
---------
Co-authored-by: Simon Heather <simon.heather@yulife.com>1 parent de617db commit d5af07d
2 files changed
Lines changed: 96 additions & 9 deletions
File tree
- packages/@cdktn/cli-core/src
- lib/dependencies
- test/lib/dependencies
Lines changed: 21 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
524 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
525 | 539 | | |
526 | 540 | | |
527 | 541 | | |
| |||
535 | 549 | | |
536 | 550 | | |
537 | 551 | | |
538 | | - | |
| 552 | + | |
539 | 553 | | |
540 | 554 | | |
541 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
542 | 558 | | |
543 | | - | |
| 559 | + | |
544 | 560 | | |
545 | 561 | | |
546 | | - | |
547 | | - | |
548 | 562 | | |
549 | | - | |
550 | | - | |
551 | | - | |
| 563 | + | |
552 | 564 | | |
553 | 565 | | |
554 | | - | |
| 566 | + | |
555 | 567 | | |
556 | 568 | | |
557 | 569 | | |
| |||
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
0 commit comments