Support "type" attribute of http_archive in bzlmod
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the feature request:
When using bzlmod the source.json file in the index repository is downloaded and translated internally into an http_archive repository rule.
http_archive provides a ["type"](https://bazel.build/rules/lib/repo/http#http_archive-type) parameter to tell what kind of archive (zip, tgz, etc...). bzlmod does not currently expose this functionality, which means that module sources that require the "type" argument cannot be used by bzlmod.
This request is to provide access to the "type" parameter of http_archive when defining a bzlmod module. "type" is already taken in sources.json, so I suggest using "archiveType" or similar.
### What underlying problem are you trying to solve with this feature?
I'm trying to host a bazel module on the [bitbucket server api](https://developer.atlassian.com/server/bitbucket/rest/v807/api-group-repository/#api-api-latest-projects-projectkey-repos-repositoryslug-archive-get), which has a way to stream a git repo as http archive, but the URL doesn't have a file extension.
The URLs are like this:
```
https://myrepo.com/rest/api/latest/projects/myproject/repos/rules_needs_type/archive?format=zip&filename=foo.zip
```
I can use http_archive with "type=zip" to use these modules in a traditional WORKSPACE, but I can't get bzlmod to download them due to the URL not having a traditional file extension.
The filename=foo.zip will add a Content-Disposition header that could be parsed to obtain the extension, but currently bazel's downloader doesn't seem to look for this kind of header when determining the type of archive. I think it will be more flexible and easier to code to add the field to source.json. Parsing the Content-Disposition is an alternative way to solve the problem.
### Which operating system are you running Bazel on?
linux
### What is the output of `bazel info release`?
release 6.1.1
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?
_No response_
### Have you found anything relevant by searching the web?
I did not find anything, although the [PR for adding git_repository](https://github.com/bazelbuild/bazel/pull/17720/files#diff-3c1659a16a6e3efcb56874ee033219649dd4b6638accbe3fa2a6cdb22b235c78) was useful to find the location in the bazel code where this can be done.
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start by following the location identified through PR #17720 and tracing how bzlmod downloads source.json and translates it into an http_archive rule. Determine how the archive type is represented and propagated, then verify that modules using extensionless URLs can provide the requested archive type through the new source.json field.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100