Skip to content

fix(crate): respect config.json in indices - #41536

Merged
viceice merged 9 commits into
renovatebot:mainfrom
lehmanju:crate-configjson
Mar 1, 2026
Merged

viceice merged 9 commits into
renovatebot:mainfrom
lehmanju:crate-configjson

Conversation

@lehmanju

@lehmanju lehmanju commented Feb 26, 2026 •

Copy link
Copy Markdown
Contributor

Changes

This PR implements proper handling of cargo registries by respecting their config.json file. Each cargo registry serves this file at the root. It contains base urls for downloading and optionally for the web api.

https://doc.rust-lang.org/cargo/reference/registry-index.html

The change implements this behavior by always consulting config.json to retrieve the correct base urls. Additionally, it removes most of the special treatment for "crates.io" since it is just a normal cargo registry.

A potentially breaking change is, that the user-defined registry "https://crates.io" does not work anymore since it has been replace with "sparse+https://index.crates.io". For most users this shouldn't be a problem, since they just use the default registry. A possible solution is to automatically map the old url to the new sparse version.

Also, the registryUrl field for a detected dependency changes as can be seen in the test files.

Context

Please select one of the following:

  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests, but ran on a real repository, or
  • Both unit tests + ran on a real repository

@github-actions
github-actions Bot requested a review from viceice February 26, 2026 22:21
@cla-assistant

cla-assistant Bot commented Feb 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread lib/modules/datasource/crate/schema.ts
Comment thread lib/modules/datasource/crate/index.ts Outdated
Comment thread lib/modules/datasource/crate/index.ts Outdated
Comment thread lib/modules/datasource/crate/index.ts Outdated
Comment thread lib/modules/datasource/crate/index.ts Outdated
Comment thread lib/modules/datasource/crate/index.ts Outdated
lehmanju and others added 3 commits February 27, 2026 16:12
Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
@lehmanju
lehmanju requested a review from viceice February 27, 2026 16:29

@viceice viceice left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nearly LGTM

@zharinov can you check the caching thing? maybe we can use one of our decorator functions to simplify?

Comment thread lib/modules/datasource/crate/index.spec.ts
@lehmanju
lehmanju requested a review from viceice February 27, 2026 17:00
@viceice
viceice requested review from zharinov and removed request for viceice February 27, 2026 17:08

@zharinov zharinov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Memory cache doesn't have decorator, and I think it's not worth it anyways

@lehmanju
lehmanju requested a review from viceice March 1, 2026 06:53
@viceice
viceice added this pull request to the merge queue Mar 1, 2026
Merged via the queue into renovatebot:main with commit 5ab5dfd Mar 1, 2026
45 checks passed
lehmanju added a commit to lehmanju/renovate that referenced this pull request Mar 2, 2026
@altaiezior

Copy link
Copy Markdown

@lehmanju when using a custom registry the getCrateMetadata method fails as it tries to query the metadata using /api/v1 but in registries such as of nexus and artifact-keeper the metadata API is not available, it is only part of crates.io and hence can be one of the reasons why crates.io was earlier being used here.

@lehmanju

Copy link
Copy Markdown
Contributor Author

Yes, I know. Thats why I have merged a logging fix recently. The /api/v1 endpoint is still part of the spec but as you say not implemented for most custom implementations. It should fail silently with the latest version.

@altaiezior

Copy link
Copy Markdown

@lehmanju do you think failed to download crate metadata should also be suppressed as it would otherwise create confusion of the call being failure

Secondly can we somehow make a quick check if the repository supports metadata API, cache that for repository and don't waste our calls if it is not supported.

In metadata we usually fetch the source repository / homepage currently, so when using custom registry a user would miss these data points, do you think falling back to crates.io for metadata would be a better choice.

We can have feature controls via configurations

@lehmanju

Copy link
Copy Markdown
Contributor Author

I don't understand, the warning suppression is already merged (#41601) and afaik there is no way of checking the implemented registry features.

@altaiezior

Copy link
Copy Markdown

I don't understand, the warning suppression is already merged (#41601) and afaik there is no way of checking the implemented registry features.

I just thought if we can save some network calls, usually when I have to debug why a dependency is not getting updated I use the debug mode and I see these failure logs before I reliased may be they don't even matter.

edbingo pushed a commit to edbingo/renovate that referenced this pull request Mar 23, 2026
* fix(crate): respect config.json in indices

* improve coverage

* improve coverage

* Apply suggestions from code review

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>

* fixup

* fix import sorting

* further simplify, by merging clonepath/sparse variable

* use registryconfigschema in tests

---------

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
edbingo pushed a commit to edbingo/renovate that referenced this pull request Mar 23, 2026
* fix(crate): respect config.json in indices

* improve coverage

* improve coverage

* Apply suggestions from code review

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>

* fixup

* fix import sorting

* further simplify, by merging clonepath/sparse variable

* use registryconfigschema in tests

---------

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
bastianwenske pushed a commit to bastianwenske/renovate that referenced this pull request Apr 7, 2026
* fix(crate): respect config.json in indices

* improve coverage

* improve coverage

* Apply suggestions from code review

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>

* fixup

* fix import sorting

* further simplify, by merging clonepath/sparse variable

* use registryconfigschema in tests

---------

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants