{"record":{"id":"9c13320c26d6d875","repo":"AdguardTeam/AdGuardHome","slug":"creating-safesearch-for-client-q-w","errorCode":null,"errorMessage":"creating safesearch for client %q: %w","messagePattern":"creating safesearch for client %q: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/home/clientshttp.go","lineNumber":228,"sourceCode":"\tc.ParentalEnabled = cj.ParentalEnabled\n\tc.SafeBrowsingEnabled = cj.SafeBrowsingEnabled\n\tc.UseOwnBlockedServices = !cj.UseGlobalBlockedServices\n\n\tif c.SafeSearchConf.Enabled {\n\t\tlogger := clients.baseLogger.With(\n\t\t\tslogutil.KeyPrefix, safesearch.LogPrefix,\n\t\t\tsafesearch.LogKeyClient, c.Name,\n\t\t)\n\t\tvar ss *safesearch.Default\n\t\tss, err = safesearch.NewDefault(ctx, &safesearch.DefaultConfig{\n\t\t\tLogger:         logger,\n\t\t\tServicesConfig: c.SafeSearchConf,\n\t\t\tClientName:     c.Name,\n\t\t\tCacheSize:      clients.safeSearchCacheSize,\n\t\t\tCacheTTL:       clients.safeSearchCacheTTL,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"creating safesearch for client %q: %w\", c.Name, err)\n\t\t}\n\n\t\tc.SafeSearch = ss\n\t}\n\n\treturn c, nil\n}\n\n// copySafeSearch returns safe search config created from provided parameters.\nfunc copySafeSearch(\n\tjsonConf *filtering.SafeSearchConfig,\n\tenabled bool,\n) (conf filtering.SafeSearchConfig) {\n\tif jsonConf != nil {\n\t\treturn *jsonConf\n\t}\n\n\t// TODO(d.kolyshev): Remove after cleaning the deprecated","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/clientshttp.go#L210-L246","documentation":"Creating the safe-search configuration for a client failed while converting JSON to a client object. The wrapped error comes from the safe-search engine when the client's SafeSearchConf is invalid or the cache settings are unusable.","triggerScenarios":"handleAddClient/handleUpdateClient (or internal consistency assertions) with a client whose SafeSearchConf fails to build into a safe-search set, e.g. invalid engine options or bad cache size/TTL values.","commonSituations":"API payloads with malformed safe-search settings, inconsistent global safe-search cache configuration, or version mismatches where the config schema changed.","solutions":["Check the wrapped error for the specific safe-search setting at fault","Simplify the request: omit safe-search fields, then re-add them one at a time","Verify global safe-search cache size/TTL configuration is sane","Upgrade both client tooling and server to matching versions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Omit or null safe_search fields when unsure\nif !validatedSafeSearch(payload.SafeSearchConf) { payload.SafeSearchConf = nil }","typeGuard":null,"tryCatchPattern":"// Degrade gracefully: resend without safe-search settings\nif isSafeSearchErr(err) { payload.SafeSearchConf = nil; retry() }","preventionTips":["Keep server and API client versions aligned","Test safe-search configs on a scratch client before bulk updates"],"tags":["clients","safe-search","validation","api"],"backgroundTag":"config-validation-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}