Skip to content

Extract IsSPOG and ResolveConfigType into libs/auth#4939

Merged
mihaimitrea-db merged 4 commits intomainfrom
mihaimitrea-db/extract-resolve-config-type
Apr 14, 2026
Merged

Extract IsSPOG and ResolveConfigType into libs/auth#4939
mihaimitrea-db merged 4 commits intomainfrom
mihaimitrea-db/extract-resolve-config-type

Conversation

@mihaimitrea-db
Copy link
Copy Markdown
Contributor

@mihaimitrea-db mihaimitrea-db commented Apr 13, 2026

Summary

  • Extract the SPOG detection heuristic into a shared IsSPOG(cfg, accountID) predicate in libs/auth/config_type.go, replacing inline checks in both profiles.go and ToOAuthArgument.
  • Extract ResolveConfigType(cfg) that wraps ConfigType() with SPOG-aware overrides, used by profiles.go.
  • ToOAuthArgument now calls IsSPOG instead of duplicating the DiscoveryURL + IsUnifiedHost checks inline.

Follow-up to #4929 as suggested in review comment #2 (logic duplication).

Note on IsUnifiedHost fallback scope

The IsSPOG predicate checks Experimental_IsUnifiedHost unconditionally (not gated on configType == InvalidConfig). This is broader than the previous inline check in profiles.go, which only fired for InvalidConfig. This is safe because the SDK currently returns InvalidConfig for all unified hosts (the UnifiedHost case was removed from ConfigType() in v0.126.0). It is also more robust against future SDK changes that might reclassify unified hosts differently.

Test plan

  • TestResolveConfigType — 9-case table-driven unit test in libs/auth/config_type_test.go.
  • All existing TestProfileLoad* and TestToOAuthArgument* tests pass.
  • go test ./libs/auth/ ./cmd/auth/ passes.

Copy link
Copy Markdown
Member

@simonfaltum simonfaltum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, clean extraction. Two small suggestions:

  1. The IsUnifiedHost fallback in ResolveConfigType is now broader than before (applies to any non-AccountConfig, not just InvalidConfig). Verified it's safe today since the SDK still returns InvalidConfig for unified hosts, and it's actually more robust against future SDK changes. Worth a quick note in the PR description so other reviewers don't have to trace through HostType() to verify.

  2. The else if err := cfg.EnsureResolved(); err == nil { // comment } pattern in arguments.go reads a bit odd since the body is empty and the error check doesn't gate anything. Something like } else { _ = cfg.EnsureResolved() } would make the side-effect intent clearer. Not a big deal though.

@mihaimitrea-db mihaimitrea-db changed the base branch from mihaimitrea-db/fix-profiles-spog-classification to main April 14, 2026 15:09
@mihaimitrea-db mihaimitrea-db added this pull request to the merge queue Apr 14, 2026
@mihaimitrea-db mihaimitrea-db removed this pull request from the merge queue due to a manual request Apr 14, 2026
Deduplicate SPOG detection logic between profiles.go and
ToOAuthArgument. IsSPOG checks DiscoveryURL and IsUnifiedHost,
ResolveConfigType wraps ConfigType with SPOG-aware overrides.
@mihaimitrea-db mihaimitrea-db force-pushed the mihaimitrea-db/extract-resolve-config-type branch from c0631cf to 27dbd85 Compare April 14, 2026 15:58
@mihaimitrea-db mihaimitrea-db added this pull request to the merge queue Apr 14, 2026
Merged via the queue into main with commit 06f4c01 Apr 14, 2026
22 checks passed
@mihaimitrea-db mihaimitrea-db deleted the mihaimitrea-db/extract-resolve-config-type branch April 14, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants