SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(preference): update user preference apis to return 200 when preference exists but has no value (#9957)
Vikrant Gupta22158a3cee1e
diff --git a/pkg/modules/preference/implpreference/module.go b/pkg/modules/preference/implpreference/module.goindex 6f2808cb77..3eb3fada97 100644--- a/pkg/modules/preference/implpreference/module.go+++ b/pkg/modules/preference/implpreference/module.go@@ -172,7 +172,6 @@ func (module *module) GetByUser(ctx context.Context, userID valuer.UUID, name prreturn nil, err}- return nil, err}if storableUserPreference != nil {diff --git a/pkg/types/preferencetypes/preference.go b/pkg/types/preferencetypes/preference.goindex 40e3ad15fc..c8ab6bafef 100644--- a/pkg/types/preferencetypes/preference.go+++ b/pkg/types/preferencetypes/preference.go@@ -140,7 +140,7 @@ func NewAvailablePreference() map[Name]Preference {Name: NameNavShortcuts,Description: "A list of shortcuts to be shown in the navigation.",ValueType: ValueTypeArray,- DefaultValue: MustNewValue([]any{}, ValueTypeArray),+ DefaultValue: MustNewValue([]any{"services", "logs", "traces", "infrastructure"}, ValueTypeArray),AllowedScopes: []Scope{ScopeUser},AllowedValues: []string{},Value: MustNewValue([]any{}, ValueTypeArray),@@ -170,7 +170,7 @@ func NewAvailablePreference() map[Name]Preference {DefaultValue: MustNewValue([]any{"deployment.environment"}, ValueTypeArray),AllowedScopes: []Scope{ScopeUser},AllowedValues: []string{},- Value: MustNewValue([]any{"deployment.environment"}, ValueTypeArray),+ Value: MustNewValue([]any{}, ValueTypeArray),},}}@@ -191,7 +191,7 @@ func NewPreference(name Name, scope Scope, available map[Name]Preference) (*PrefValueType: preference.ValueType,DefaultValue: preference.DefaultValue,AllowedScopes: preference.AllowedScopes,- Value: preference.DefaultValue,+ Value: preference.Value,}, nil}diff --git a/tests/integration/src/preference/a_user.py b/tests/integration/src/preference/a_user.pyindex 8012d0a2cd..748371ac1f 100644--- a/tests/integration/src/preference/a_user.py+++ b/tests/integration/src/preference/a_user.py@@ -46,6 +46,20 @@ def test_get_set_user_preference_by_name(# This should be NOT_FOUNDassert response.status_code == HTTPStatus.BAD_REQUEST+ # get preference by name+ response = requests.get(+ signoz.self.host_configs["8080"].get(+ "/api/v1/user/preferences/welcome_checklist_do_later"+ ),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.OK+ assert response.json()["data"] is not None+ assert response.json()["data"]["defaultValue"] is False+ assert response.json()["data"]["value"] is False+# play with welcome_checklist_do_later preferenceresponse = requests.put(signoz.self.host_configs["8080"].get(diff --git a/tests/integration/src/preference/b_org.py b/tests/integration/src/preference/b_org.pyindex a073090b25..7036e9a1a7 100644--- a/tests/integration/src/preference/b_org.py+++ b/tests/integration/src/preference/b_org.py@@ -46,6 +46,18 @@ def test_get_set_org_preference_by_name(# This should be NOT_FOUNDassert response.status_code == HTTPStatus.BAD_REQUEST+ # get preference by name+ response = requests.get(+ signoz.self.host_configs["8080"].get("/api/v1/org/preferences/org_onboarding"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.OK+ assert response.json()["data"] is not None+ assert response.json()["data"]["defaultValue"] is False+ assert response.json()["data"]["value"] is False+# play with org_onboarding preferenceresponse = requests.put(signoz.self.host_configs["8080"].get("/api/v1/org/preferences/org_onboarding"),