astrid-runtime/astrid · error
GitHub releases URL cannot be a base
Error message
GitHub releases URL cannot be a base
What it means
`release_tag_url` builds the GitHub API releases URL and then appends `tags/<tag>` via `Url::path_segments_mut`. That method returns `Err(())` when the URL cannot have path segments — a cannot-be-a-base URL — which should be impossible for the https URL constructed here, so this error indicates an internal invariant violation rather than user input.
Solutions
- Verify org/repo/tag inputs are plain identifiers without `:`, `//`, or control characters
- If you modified the base URL string, ensure it remains a special (http/https) URL so it has path segments
- Update astrid-cli — as shipped this is an internal bug and worth reporting
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure identifiers are URL-safe before calling:
fn url_safe_id(s: &str) -> bool {
!s.is_empty() && s.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_' || c == '.')
} Try / catch
match result {
Err(e) if e.to_string().contains("cannot be a base") => {
eprintln!("Internal URL construction bug; report org/repo values used.");
}
other => other?,
} Prevention
- Keep org/repo/tag values as plain URL-safe identifiers
- Sanitize inputs interpolated into URL templates
- Report occurrences upstream — as shipped this path should be unreachable
When it happens
Trigger: Practically unreachable: it fires only if `reqwest::Url::parse` produced a cannot-be-a-base URL for `https://api.github.com/repos/{org}/{repo}/releases`, or if the org/repo/tag strings contain characters that break parsing such that the parsed URL is opaque (e.g. embedded scheme/control characters via unsanitized input).
Common situations: Only seen if the surrounding code changes the base URL template, or if org/repo values interpolated into the URL contain malicious/odd characters that alter URL parsing.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- GitHub API error querying release tag
- GitHub API returned fetching release of /
- GitHub API returned for / latest release
- GitHub release has missing or empty tag_name
- Invalid GitHub URL format. Expected github.com/org/repo or…
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/4a958d531d558389.
Report an issue: GitHub.
Appendix: source
Thrown at crates/astrid-cli/src/commands/capsule/install_github.rs:42
(not a valid HTTP header value); proceeding with anonymous GitHub API access"
),
}
}
reqwest::Client::builder()
.user_agent("astrid-cli")
.timeout(std::time::Duration::from_secs(30))
.default_headers(headers)
.build()
.context("failed to build GitHub HTTP client")
}
pub(super) fn release_tag_url(org: &str, repo: &str, tag: &str) -> anyhow::Result<String> {
let mut url = reqwest::Url::parse(&format!(
"https://api.github.com/repos/{org}/{repo}/releases"
))
.context("failed to build GitHub releases URL")?;
url.path_segments_mut()
.map_err(|()| anyhow::anyhow!("GitHub releases URL cannot be a base"))?
.push("tags")
.push(tag);
Ok(url.to_string())
}
pub(super) async fn resolve_github_ref(
client: &reqwest::Client,
org: &str,
repo: &str,
version: Option<&str>,
tag: Option<&str>,
) -> anyhow::Result<String> {
if let Some(tag) = tag {
return Ok(tag.to_string());
}
if let Some(version) = version {
for candidate in [format!("v{version}"), version.to_string()] {
let tag_url = release_tag_url(org, repo, &candidate)?;View on GitHub (pinned to affd8760f4)