router-for-me/CLIProxyAPI · warning

source auth path is empty

Error message

source auth path is empty

What it means

setSourceAuthFileDisabled was called with a path that is empty after trimming. The caller derives the path from the auth's AttributeVirtualSource or fallback "path" attribute; an empty result means the target auth record has neither attribute, so there is no file to write and the operation is rejected as a record-shape error rather than guessing a path.

Source

Thrown at internal/api/handlers/management/auth_files_fields.go:157

			continue
		}
		if !sameAuthFilePath(authAttribute(auth, "path"), sourcePath) &&
			!sameAuthFilePath(authAttribute(auth, coreauth.AttributeVirtualSource), sourcePath) {
			continue
		}
		applyAuthDisabledState(auth, disabled)
		auth.UpdatedAt = now
		if _, errUpdate := h.authManager.Update(ctx, auth); errUpdate != nil {
			return fmt.Errorf("failed to update auth %s: %w", auth.ID, errUpdate)
		}
	}
	return nil
}

func setSourceAuthFileDisabled(path string, disabled bool) error {
	path = strings.TrimSpace(path)
	if path == "" {
		return fmt.Errorf("source auth path is empty")
	}
	data, errRead := os.ReadFile(path)
	if errRead != nil {
		return errRead
	}
	metadata := make(map[string]any)
	if len(bytes.TrimSpace(data)) > 0 {
		if errUnmarshal := json.Unmarshal(data, &metadata); errUnmarshal != nil {
			return fmt.Errorf("invalid auth file: %w", errUnmarshal)
		}
	}
	if metadata == nil {
		metadata = make(map[string]any)
	}
	metadata["disabled"] = disabled
	raw, errMarshal := json.Marshal(metadata)
	if errMarshal != nil {
		return fmt.Errorf("marshal auth file: %w", errMarshal)

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Inspect the target auth record's attributes via the management GET endpoint and confirm which attribute should hold its source path
  2. Re-create or repair the credential through the normal login/import flow so path metadata is populated
  3. If the record intentionally has no file, toggle it via the regular auth update endpoint (authManager.Update path) instead of the plugin-virtual-source path
  4. Fix upstream code that constructed the record without setting path/virtual-source

Example fix

// before
patchPluginVirtualSourceStatus(ctx, authWithoutPath, true)
// after: ensure the record carries its source file
auth.Attributes["path"] = "/app/auths/plugin-source.json"
patchPluginVirtualSourceStatus(ctx, auth, true)
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(authAttribute(auth, coreauth.AttributeVirtualSource)) == "" &&
   strings.TrimSpace(authAttribute(auth, "path")) == "" {
    return errors.New("auth has no source path; use the standard auth update endpoint instead")
}

Type guard

func hasSourcePath(auth *coreauth.Auth) bool {
    return auth != nil && (strings.TrimSpace(authAttribute(auth, coreauth.AttributeVirtualSource)) != "" ||
        strings.TrimSpace(authAttribute(auth, "path")) != "")
}

Prevention

When it happens

Trigger: Toggling disabled on a plugin virtual auth whose record lacks both the virtual-source and path attributes (malformed record, or an auth type that never had a backing file); calling the internal helper directly with an untrimmed empty string.

Common situations: Auth records created by an older version or a custom synthesizer that omits the path attribute; records loaded from an external store with stripped attributes; upstream bugs that build targetAuth from partial data.

Related errors


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/96e24b79806a75a1. Report an issue: GitHub.