Extract IsSPOG and ResolveConfigType into libs/auth#4939
Extract IsSPOG and ResolveConfigType into libs/auth#4939mihaimitrea-db merged 4 commits intomainfrom
Conversation
simonfaltum
left a comment
There was a problem hiding this comment.
Looks good, clean extraction. Two small suggestions:
-
The
IsUnifiedHostfallback inResolveConfigTypeis now broader than before (applies to any non-AccountConfig, not justInvalidConfig). Verified it's safe today since the SDK still returnsInvalidConfigfor 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 throughHostType()to verify. -
The
else if err := cfg.EnsureResolved(); err == nil { // comment }pattern inarguments.goreads 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.
Deduplicate SPOG detection logic between profiles.go and ToOAuthArgument. IsSPOG checks DiscoveryURL and IsUnifiedHost, ResolveConfigType wraps ConfigType with SPOG-aware overrides.
c0631cf to
27dbd85
Compare
Summary
IsSPOG(cfg, accountID)predicate inlibs/auth/config_type.go, replacing inline checks in bothprofiles.goandToOAuthArgument.ResolveConfigType(cfg)that wrapsConfigType()with SPOG-aware overrides, used byprofiles.go.ToOAuthArgumentnow callsIsSPOGinstead of duplicating theDiscoveryURL+IsUnifiedHostchecks inline.Follow-up to #4929 as suggested in review comment #2 (logic duplication).
Note on IsUnifiedHost fallback scope
The
IsSPOGpredicate checksExperimental_IsUnifiedHostunconditionally (not gated onconfigType == InvalidConfig). This is broader than the previous inline check inprofiles.go, which only fired forInvalidConfig. This is safe because the SDK currently returnsInvalidConfigfor all unified hosts (theUnifiedHostcase was removed fromConfigType()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 inlibs/auth/config_type_test.go.TestProfileLoad*andTestToOAuthArgument*tests pass.go test ./libs/auth/ ./cmd/auth/passes.