fix(store): handle global scope in normalizeScope#428
Merged
Conversation
normalizeScope had no case for "global", silently coercing it to "project". Add "global" alongside "personal" in the switch so mem_save/mem_update/HTTP API callers can create and upsert global observations correctly. Closes #122
There was a problem hiding this comment.
Pull request overview
This PR fixes internal/store scope normalization so that "global" is treated as a valid scope instead of being silently coerced to "project", restoring the ability to create/update/upsert global observations through all call paths that rely on normalizeScope().
Changes:
- Update
normalizeScope()to explicitly accept"global"(alongside"personal") and otherwise default to"project". - Add a table-driven unit test covering normalization behavior for
"global"variants and confirming existing behavior for other inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/store/store.go | Extends normalizeScope() to preserve "global" rather than defaulting it to "project". |
| internal/store/store_test.go | Adds TestNormalizeScopeHandlesGlobal to verify "global" normalization and unchanged defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…lobal # Conflicts: # internal/store/store_test.go
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
normalizeScope()ininternal/store/store.gohad nocaseforglobal, silently coercing it toprojectvia the fallthrough default.mem_save/mem_update/ CLI / HTTP call withscope: "global"storedprojectinstead, making global observations impossible to create or upsert.case "personal", "global": return v, acceptingglobalas a third valid scope.Test plan
TestNormalizeScopeHandlesGlobal— 10 table-driven subtests covering case/whitespace variants ofglobal, plus unchanged behavior forpersonal,project, empty, and unknown inputsgo test ./... && go vet ./... && go build ./...cleanCloses #122