fix: validate persisted workflow modes#28
Open
KalleBylin wants to merge 2 commits intogastownhall:mainfrom
Open
fix: validate persisted workflow modes#28KalleBylin wants to merge 2 commits intogastownhall:mainfrom
KalleBylin wants to merge 2 commits intogastownhall:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is a direct follow-up to #17, responding to the reviewer’s note about
ResolveMode()allowing invalid persisted mode strings to pass through unchanged.In #17, the default workflow mode behavior was clarified so unset mode resolves to
pr, matching the intended behavior and README. During review, a related gap was called out: explicit invalid persisted values such as"typo"were still able to survive and reach downstream behavior. This PR addresses that issue directly.The fix hardens workflow mode validation at the persistence / resolution boundary for both:
What changed
modeon load and save.connect/joinnow reject invalid explicit mode values before persisting metadata.Why this approach
The problem here is not just input validation at one setter. The real risk is invalid persisted state surviving long enough to produce inconsistent downstream behavior.
This change therefore hardens the config boundary itself:
""=>pr)That keeps valid
prandwild-westbehavior unchanged while making invalid persisted state fail loudly and deterministically.Hosted rationale
While implementing the local config fix, I found the same workflow-mode concept persisted separately in hosted metadata. The hosted
connect/joinpath and hosted resolver had the same class of problem: invalid explicit values could still be stored and only fail later with mixed semantics.Because this PR is specifically about hardening persisted workflow-mode handling, I included the hosted path in the same change rather than leaving local and hosted behavior inconsistent.
Tests
Added / updated coverage for:
connectmode rejectedjoinmode rejectedVerification
Passed:
go test ./internal/hosted ./internal/api ./internal/federation ./cmd/wlgo vet ./...go test ./...Not verified via repo wrapper:
make checkstill fails in the existinggolangci-lintstep with:context loading failed: no go files to analyzeFollow-up
While working on this, I also noticed a separate local-config enumeration issue:
ResolveConfig/wl list/wl doctorstill reason from raw filenames returned byList()before each config is validated on load. That means invalid config files can still influence ambiguity / joined-count UX before the load error is surfaced.I am intentionally leaving that as a follow-up so this PR stays focused on the reviewer-raised invalid-mode hardening issue and the matching hosted resolver boundary.