{"record":{"id":"07cb698fa511b465","repo":"Tencent/WeKnora","slug":"invalid-metaso-search-scope-s","errorCode":null,"errorMessage":"invalid Metaso search scope: %s","messagePattern":"invalid Metaso search scope: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/metaso.go","lineNumber":60,"sourceCode":"\t\treturn nil, err\n\t}\n\tclient, err := NewSearchHTTPClient(defaultMetasoTimeout, params.ProxyURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &MetasoProvider{\n\t\tclient: client, baseURL: defaultMetasoSearchURL,\n\t\tapiKey: strings.TrimSpace(params.APIKey), scope: metasoScope(params.ExtraConfig),\n\t}, nil\n}\n\nfunc ValidateMetasoParameters(params types.WebSearchProviderParameters) error {\n\tif strings.TrimSpace(params.APIKey) == \"\" {\n\t\treturn fmt.Errorf(\"API key is required for Metaso provider\")\n\t}\n\tscope := metasoScope(params.ExtraConfig)\n\tif _, ok := validMetasoScopes[scope]; !ok {\n\t\treturn fmt.Errorf(\"invalid Metaso search scope: %s\", scope)\n\t}\n\treturn nil\n}\n\nfunc metasoScope(extraConfig map[string]string) string {\n\tif scope := strings.TrimSpace(extraConfig[\"scope\"]); scope != \"\" {\n\t\treturn scope\n\t}\n\treturn defaultMetasoScope\n}\n\nfunc (p *MetasoProvider) Name() string { return \"metaso\" }\n\nfunc (p *MetasoProvider) Search(ctx context.Context, query string, maxResults int, includeDate bool) ([]*types.WebSearchResult, error) {\n\tquery = strings.TrimSpace(query)\n\tif query == \"\" {\n\t\treturn nil, fmt.Errorf(\"query is empty\")\n\t}","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/metaso.go#L42-L78","documentation":"Returned by ValidateMetasoParameters when the configured Metaso search scope (derived from ExtraConfig[\"scope\"]) is not one of the entries in validMetasoScopes. Metaso only accepts a fixed set of scopes (e.g. webpage/document/image etc.), and an unknown value would cause API-side rejections, so the provider validates it up front. The invalid value is included in the message.","triggerScenarios":"NewMetasoProvider -> ValidateMetasoParameters where metasoScope(params.ExtraConfig) returns a value not in validMetasoScopes — e.g. ExtraConfig{scope: \"web\"} when the provider expects \"webpage\", a typo, or wrong casing.","commonSituations":"Copy-pasted scope name from another provider's config; typo like \"webpages\" vs \"webpage\"; user-facing setting passing free-form text into scope; empty-but-set value that skips the default and is not whitelisted.","solutions":["Check the error message for the offending scope value and compare against the provider's validMetasoScopes list (see metaso.go).","Set ExtraConfig[\"scope\"] to one of the documented valid values (or omit it entirely to use the default).","Fix casing/typos — scopes are matched exactly, not case-insensitively.","Add a whitelist check in your own config loading to reject bad scopes before constructing the provider."],"exampleFix":"// before\ncfg := types.WebSearchProviderParameters{APIKey: key, ExtraConfig: map[string]string{\"scope\": \"web\"}}\n\n// after: use a documented valid scope\ncfg := types.WebSearchProviderParameters{APIKey: key, ExtraConfig: map[string]string{\"scope\": \"webpage\"}}","handlingStrategy":"validation","validationCode":"var validMetasoScopes = map[string]bool{\"webpage\": true, \"document\": true, \"image\": true}\n\nscope := strings.TrimSpace(cfg.ExtraConfig[\"scope\"])\nif scope != \"\" && !validMetasoScopes[scope] {\n    return fmt.Errorf(\"invalid Metaso scope %q; valid: webpage, document, image\", scope)\n}","typeGuard":null,"tryCatchPattern":"if err := ValidateMetasoParameters(params); err != nil {\n    if strings.Contains(err.Error(), \"invalid Metaso search scope\") {\n        return nil, fmt.Errorf(\"check your scope setting: %w\", err)\n    }\n    return err\n}","preventionTips":["Expose scopes as a fixed enum in your own config layer, not free-form strings.","Copy scope names from the provider's documentation/validMetasoScopes, not from other providers.","Add a unit test asserting every scope your app configures passes ValidateMetasoParameters.","Prefer omitting ExtraConfig[\"scope\"] to use the default when unsure."],"tags":["config","validation","enum","web-search"],"backgroundTag":"invalid-enum-value","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}