Skip to content

fix: admin teams fetch produces excessive warnings for large orgs #23

Description

@raiderrobert

Problem

When running ownrs org <org> --refresh, the admin teams fetch produces hundreds of warning lines to stderr:

Warning: failed to fetch teams for <org>/<repo>: GitHub
Warning: failed to fetch teams for <org>/<repo>: GitHub
Warning: failed to fetch teams for <org>/<repo>: GitHub
... (200+ lines)

This obscures the actual output and makes the tool noisy. These are expected 403 errors for repos the user doesn't have admin access to.

Root cause

In src/sources/fetcher.rs, fetch_admin_teams matches errors by checking if the error string contains the literal strings "403" or "404":

Err(e) => {
    let err_str = e.to_string();
    if err_str.contains("403") || err_str.contains("404") {
        break;
    }
    eprintln!("Warning: failed to fetch teams for {org}/{repo}: {e}");
    break;
}

This string-matching approach is fragile — the octocrab error type may not include the HTTP status code in its Display output, causing expected 403 errors to fall through to the warning branch.

Suggested fix

  • Suppress or aggregate warnings — these are expected permission errors, not actionable. Options:
    • Silently return empty for all API errors (user simply doesn't have access)
    • Aggregate into a single summary line: Note: could not fetch admin teams for 200 repos (insufficient permissions)
    • Only print individual warnings in a --verbose mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions