{"record":{"id":"54ec203e14bc4513","repo":"weaviate/weaviate","slug":"parse-sentry-config-from-env-w","errorCode":null,"errorMessage":"parse sentry config from env: %w","messagePattern":"parse sentry config from env: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/config/environment.go","lineNumber":1397,"sourceCode":"\tconfig.Restrictions.AllowedVectorIndexTypes = allowVectorDV\n\tvar allowCompression []string\n\tif v := os.Getenv(\"ALLOWED_COMPRESSION_TYPES\"); v != \"\" {\n\t\tallowCompression = strings.Split(v, \",\")\n\t}\n\tallowCompressionDV, err := configRuntime.NewDynamicValueWithValidation(allowCompression, NewRestrictionCompressionTypeListValidator())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parse ALLOWED_COMPRESSION_TYPES: %w\", err)\n\t}\n\tconfig.Restrictions.AllowedCompressionTypes = allowCompressionDV\n\tparseString(\"RESTRICTIONS_ERROR_MESSAGE\", func(val string) {\n\t\tconfig.Restrictions.ErrorMessage = configRuntime.NewDynamicValue(val)\n\t}, DefaultRestrictionsErrorMessage)\n\n\t// explicitly reset sentry config\n\tsentry.Config = nil\n\tconfig.Sentry, err = sentry.InitSentryConfig()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parse sentry config from env: %w\", err)\n\t}\n\n\tconfig.MetadataServer.Enabled = false\n\tif entcfg.Enabled(os.Getenv(\"EXPERIMENTAL_METADATA_SERVER_ENABLED\")) {\n\t\tconfig.MetadataServer.Enabled = true\n\t}\n\tconfig.MetadataServer.GrpcListenAddress = DefaultMetadataServerGrpcListenAddress\n\tif v := os.Getenv(\"EXPERIMENTAL_METADATA_SERVER_GRPC_LISTEN_ADDRESS\"); v != \"\" {\n\t\tconfig.MetadataServer.GrpcListenAddress = v\n\t}\n\tif err := parsePositiveInt(\n\t\t\"EXPERIMENTAL_METADATA_SERVER_DATA_EVENTS_CHANNEL_CAPACITY\",\n\t\tfunc(val int) { config.MetadataServer.DataEventsChannelCapacity = val },\n\t\tDefaultMetadataServerDataEventsChannelCapacity,\n\t); err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":1379,"sourceCodeEnd":1415,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/config/environment.go#L1379-L1415","documentation":"At the end of FromEnv the sentry config is reset (sentry.Config = nil) and rebuilt from the environment via sentry.InitSentryConfig(); any failure is wrapped as \"parse sentry config from env: %w\". The inner error names which SENTRY_* variable (DSN, traces sample rate, environment, etc.) was malformed. Startup aborts so error reporting is never left half-configured.","triggerScenarios":"SENTRY_* env vars (e.g. SENTRY_DSN invalid URL, SENTRY_TRACES_SAMPLE_RATE=\"0.5x\" or out of [0,1], SENTRY_ENVIRONMENT issues) fail InitSentryConfig while LoadConfig runs.","commonSituations":"Pasting a DSN with surrounding quotes/whitespace; setting a sample rate like \"50\" instead of \"0.5\"; leftover SENTRY_* vars from a copied compose file pointing at a decommissioned project.","solutions":["Read the inner error after \"parse sentry config from env:\" to identify the offending SENTRY_* variable","Fix that variable — SENTRY_DSN must be a valid URL like https://key@host/project and SENTRY_TRACES_SAMPLE_RATE a float in [0,1]","Remove all SENTRY_* variables to disable Sentry entirely (config is explicitly reset to nil here anyway)"],"exampleFix":"// before\nSENTRY_TRACES_SAMPLE_RATE=50%\n\n// after\nSENTRY_TRACES_SAMPLE_RATE=0.5","handlingStrategy":"validation","validationCode":"if dsn := os.Getenv(\"SENTRY_DSN\"); dsn != \"\" {\n    if u, err := url.Parse(dsn); err != nil || u.Scheme == \"\" || u.Host == \"\" {\n        return fmt.Errorf(\"SENTRY_DSN is not a valid URL: %q\", dsn)\n    }\n}\nif r := os.Getenv(\"SENTRY_TRACES_SAMPLE_RATE\"); r != \"\" {\n    f, err := strconv.ParseFloat(r, 64)\n    if err != nil || f < 0 || f > 1 {\n        return fmt.Errorf(\"SENTRY_TRACES_SAMPLE_RATE must be a float in [0,1], got %q\", r)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := LoadConfig(...); err != nil {\n    if strings.Contains(err.Error(), \"parse sentry config from env:\") {\n        log.Fatalf(\"sentry env config invalid (check SENTRY_DSN / sample rates): %v\", err)\n    }\n    return err\n}","preventionTips":["Validate SENTRY_DSN is a full URL with scheme, key, host and project id","Sample rates are floats in [0,1], not percentages","Strip quotes/whitespace from DSN values in env files","Remove all SENTRY_* vars to disable Sentry cleanly"],"tags":["config","sentry","environment-variable","startup"],"backgroundTag":"invalid-env-var-format","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}