JuliusBrussee/caveman · error
invalid Claude organization id
Error message
invalid Claude organization id
What it means
After reading CAVEMAN_CLAUDE_ORG_ID, fetchClaudeUsageJSON rejects ids containing '/' or '..' because the org id is interpolated into the URL path https://claude.ai/api/organizations/<orgID>/usage. This is a path-traversal/URL-injection guard ensuring the id is a plain organization identifier.
Solutions
- Set CAVEMAN_CLAUDE_ORG_ID to the bare id (the URL segment between /organizations/ and /usage)
- Strip scheme/host/path if you copied a full URL, keeping only the org id
- Reject or trim the value in wrapper scripts before export
Example fix
// before export CAVEMAN_CLAUDE_ORG_ID="https://claude.ai/api/organizations/org-123/usage" // after export CAVEMAN_CLAUDE_ORG_ID="org-123"
Defensive patterns
Strategy: validation
Validate before calling
org := os.Getenv("CAVEMAN_CLAUDE_ORG_ID")
if strings.ContainsAny(org, "/") || strings.Contains(org, "..") {
return errors.New("CAVEMAN_CLAUDE_ORG_ID must be a bare organization id, not a URL")
} Type guard
func validOrgID(s string) bool {
return s != "" && !strings.Contains(s, "/") && !strings.Contains(s, "..")
} Try / catch
if err := runUsage(); err != nil {
if strings.Contains(err.Error(), "invalid Claude organization id") {
// instruct user to paste only the id segment
}
} Prevention
- Copy only the id segment from the claude.ai URL
- Validate org id format before exporting the env var
- Sanitize inputs in wrapper scripts
When it happens
Trigger: CAVEMAN_CLAUDE_ORG_ID containing slashes or '..' — e.g. pasting a full claude.ai URL as the org id, or a path-like value that would escape the API path segment.
Common situations: Copy-pasting 'https://claude.ai/api/organizations/org-123/usage' into the ORG_ID var instead of just 'org-123'; an id accidentally including a trailing slash or relative segments.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- caveman build: config must use strict lock and required…
- header cannot be forwarded
- : every source must be HTTPS
- must be an absolute http(s) URL without credentials
- must be an absolute http(s) URL without credentials
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/9ddcfc3e9ef73175.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/internal/store/usage_import.go:134
if err := json.Unmarshal([]byte(raw), &v); err != nil {
return ImportSummary{}, fmt.Errorf("parse Claude usage JSON: %w", err)
}
quotas := quotaEventsFromAny("anthropic", "claude_usage_link", "linked_api", time.Now().UTC().Format(time.RFC3339), v)
n, err := s.InsertQuotaEvents(quotas)
if err != nil {
return ImportSummary{}, err
}
return ImportSummary{Source: "claude", QuotaImported: n, Basis: "linked_api"}, nil
}
func fetchClaudeUsageJSON() ([]byte, error) {
sessionKey := os.Getenv("CAVEMAN_CLAUDE_SESSION_KEY")
orgID := os.Getenv("CAVEMAN_CLAUDE_ORG_ID")
if sessionKey == "" || orgID == "" {
return nil, fmt.Errorf("Claude usage refresh needs CAVEMAN_CLAUDE_USAGE_JSON or CAVEMAN_CLAUDE_SESSION_KEY plus CAVEMAN_CLAUDE_ORG_ID")
}
if strings.Contains(orgID, "/") || strings.Contains(orgID, "..") {
return nil, fmt.Errorf("invalid Claude organization id")
}
req, err := http.NewRequest("GET", "https://claude.ai/api/organizations/"+orgID+"/usage", nil)
if err != nil {
return nil, err
}
req.Header.Set("accept", "application/json")
req.Header.Set("cookie", "sessionKey="+sessionKey)
client := http.Client{Timeout: 15 * time.Second}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return nil, fmt.Errorf("Claude usage request failed with HTTP %d", resp.StatusCode)
}
return io.ReadAll(io.LimitReader(resp.Body, 4<<20))
}View on GitHub (pinned to 3ee70a1026)