cli: dedup mirror-active filter and cell-fallback logging · Entire

cli: dedup mirror-active filter and cell-fallback logging

95c716d · Soph · 1w ago · 2 files · +20 added/-15 removed

Cleanups from a simplify pass over the activity/recap routing:

No behaviour change.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Sessions

8d8cf40beade View transcript

Changes

2

27 unmodified lines

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
37 unmodified lines

88
89
90
82
83
84
85
91
92
93
94

27 unmodified lines

func runAuthenticatedActivityAPI(ctx context.Context, errW io.Writer, insecureHTTP bool, fn func(context.Context, *api.Client) error) error {
    client, err := auth.NewEntireAPICellClient(ctx, insecureHTTP, nil)
    if err != nil {
        if !errors.Is(err, auth.ErrNoCellForJurisdiction) {
            logging.Debug(ctx, "activity/recap: entire-api cell client unavailable, using data API", "error", err.Error())
        }
        logCellClientFallback(ctx, err)
        return runAuthenticatedDataAPI(ctx, errW, insecureHTTP, fn)
    }
    return fn(ctx, client)
}

// logCellClientFallback records, at debug, that an activity/recap command fell back from the entire-api cell to the data API. The expected cases — the region has no cell yet, or the caller isn't logged in — aren't logged: they are normal during rollout and on first use, not diagnosable failures.
func logCellClientFallback(ctx context.Context, err error) {
    if errors.Is(err, auth.ErrNoCellForJurisdiction) || errors.Is(err, auth.ErrNotLoggedIn) {
        return
    }
    logging.Debug(ctx, "activity/recap: entire-api cell client unavailable, using data API", "error", err.Error())
}

// forgeToMirrorProvider maps a gitremote forge identifier (e.g. "gh") to the upstream provider the control plane records mirrors under (e.g. "github"). entire-api routing only supports GitHub mirrors today.

// and failed/suspended placements are skipped — they can't answer for the repo.
func firstActiveRepoID(mirrors []coreapi.Mirror) string {
    for i := range mirrors {
        if mirrors[i].IsArchived.Or(false) {
            continue
        }
        if st := mirrors[i].Status.Or(coreapi.MirrorStatusReady); st == coreapi.MirrorStatusFailed || st == coreapi.MirrorStatusSuspended {
            if !isActiveMirror(mirrors[i]) {
                continue
            }
            if id := strings.TrimSpace(mirrors[i].MirrorId); id != "" {