commit 9ec71fde2146bc8acdd81978b5958f5bb9b7a87d
parent ec39ca085b8fba16a8e27f8155a2409d4d89fd18
Author: Sean Enck <sean@ttypty.com>
Date: Tue, 14 Oct 2025 16:51:35 -0400
update error message text to be more descriptive of the problem
Diffstat:
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/internal/kdbx/actions_test.go b/internal/kdbx/actions_test.go
@@ -118,7 +118,7 @@ func TestInserts(t *testing.T) {
if err := setup(t).Insert("a", map[string]string{"randomfield": "1"}); err.Error() != "unknown entity field: randomfield" {
t.Errorf("wrong error: %v", err)
}
- if err := setup(t).Insert("tests", map[string]string{"notes": "1"}); err.Error() != "input paths must contain at LEAST 2 components" {
+ if err := setup(t).Insert("tests", map[string]string{"notes": "1"}); err.Error() != "input paths must contain at LEAST 2 components (excluding field)" {
t.Errorf("wrong error: %v", err)
}
if err := setup(t).Insert("tests//l", map[string]string{"notes": "test"}); err.Error() != "unwilling to operate on path with empty segment" {
@@ -130,7 +130,7 @@ func TestInserts(t *testing.T) {
if err := setup(t).Insert("/tests", map[string]string{"password": "test"}); err.Error() != "path can NOT be rooted" {
t.Errorf("wrong error: %v", err)
}
- if err := setup(t).Insert("test", map[string]string{"otp": "test", "url": "xyz"}); err.Error() != "input paths must contain at LEAST 2 components" {
+ if err := setup(t).Insert("test", map[string]string{"otp": "test", "url": "xyz"}); err.Error() != "input paths must contain at LEAST 2 components (excluding field)" {
t.Errorf("wrong error: %v", err)
}
if err := setup(t).Insert("a", nil); err.Error() != "empty secrets not allowed" {
@@ -189,7 +189,7 @@ func TestRemoves(t *testing.T) {
if err := setup(t).Remove(nil); err.Error() != "entity is empty/invalid" {
t.Errorf("wrong error: %v", err)
}
- if err := setup(t).Remove(&kdbx.Entity{}); err.Error() != "input paths must contain at LEAST 2 components" {
+ if err := setup(t).Remove(&kdbx.Entity{}); err.Error() != "input paths must contain at LEAST 2 components (excluding field)" {
t.Errorf("wrong error: %v", err)
}
tx := kdbx.Entity{Path: kdbx.NewPath("test1", "test2", "test3")}
diff --git a/internal/kdbx/core.go b/internal/kdbx/core.go
@@ -15,7 +15,7 @@ import (
)
var (
- errPath = errors.New("input paths must contain at LEAST 2 components")
+ errPath = errors.New("input paths must contain at LEAST 2 components (excluding field)")
// AllowedFields are the same of allowed names for storing in a kdbx entry
AllowedFields = []string{NotesField, OTPField, "Password", URLField}
)
diff --git a/internal/kdbx/query_test.go b/internal/kdbx/query_test.go
@@ -131,7 +131,7 @@ func TestGet(t *testing.T) {
if err != nil || q != nil {
t.Error("invalid result, should be empty")
}
- if _, err := fullSetup(t, true).Get("aaaa", kdbx.BlankValue); err.Error() != "input paths must contain at LEAST 2 components" {
+ if _, err := fullSetup(t, true).Get("aaaa", kdbx.BlankValue); err.Error() != "input paths must contain at LEAST 2 components (excluding field)" {
t.Errorf("invalid error: %v", err)
}
}