<#1159 osctrl-cli shell: keep tag type on API-mode...
# osctrl
g
#1159 osctrl-cli shell: keep tag type on API-mode edit, save tags on DB-mode add Pull request opened by javuto osctrl-cli shell: keep tag type on API-mode edit, save tags on DB-mode add Problem Two bugs in the interactive shell's tag commands (
cmd/cli/shell_store.go
): 1. API-mode
tag edit
rewrote the tag type.
When no type was given, the shell sent
parseTagType("")
, which falls through to
Custom
. The server's edit handler changes the type whenever it differs, so editing any non-custom tag's description or color (for example) silently turned it into a Custom tag. This is the same class of bug fixed for the regular CLI commands in #1158. 2. DB-mode
tag add
never saved the tag.
dbStore.AddTag
called
TagManager.New
, which only builds the tag in memory.
NewTag
is the call that builds and stores it. The shell reported success, but no tag was created. What changes • `apiStore.EditTag`: when no type is given, read the tag first and send its stored type. An explicit type is still parsed and sent as before. • `dbStore.AddTag`: call
TagManager.NewTag
, so the tag is stored. Security and operational impact • Tags edited from the shell in API mode keep their type. Tags added from the shell in database mode now exist. • No server, API or schema changes. The regular CLI commands are unchanged. Validation • New
TestShellStoreEditTagKeepsUnsetType
runs against both shell stores. It creates a non-custom tag, edits only its description, and checks that type, custom value and color are unchanged. • Before the fix: • database mode failed with "record not found", because the tag was never saved; • with the API-mode change reverted, the type went from 6 (Tag) to 4 (Custom). •
golangci-lint
reports 0 issues on
cmd/cli
, and
go test ./...
passes on an uncached run. jmpsec/osctrl