{"record":{"id":"4a4833fb97acfa8c","repo":"gofr-dev/gofr","slug":"organization-id-must-not-be-empty","errorCode":null,"errorMessage":"organization id must not be empty","messagePattern":"organization id must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/influxdb/influxdb.go","lineNumber":51,"sourceCode":"\tmetrics Metrics\n\ttracer  trace.Tracer\n}\n\ntype HealthInflux struct {\n\tURL      string\n\tToken    string\n\tUsername string\n\tPassword string\n}\n\nconst (\n\tstatusDown = \"DOWN\"\n\tstatusUp   = \"UP\"\n)\n\nvar (\n\terrEmptyOrganizationName = errors.New(\"organization name must not be empty\")\n\terrEmptyOrganizationID   = errors.New(\"organization id must not be empty\")\n\terrEmptyBucketID         = errors.New(\"bucket id must not be empty\")\n\terrEmptyBucketName       = errors.New(\"bucket name must not be empty\")\n\terrFetchOrganization     = errors.New(\"failed to fetch all organizations\")\n\terrHealthCheckFailed     = errors.New(\"influxdb health check failed\")\n)\n\n// CreateOrganization creates a new organization in InfluxDB with the specified name.\n// It implements the container.InfluxDBProvider interface.\n//\n// Parameters:\n// - ctx: Context for request cancellation and timeouts.\n// - orgName: The name of the organization to be created. Must not be empty.\n//\n// Returns:\n// - string: The ID of the newly created organization.\n// - error: Error if organization creation fails or if orgName is empty.\nfunc (c *Client) CreateOrganization(ctx context.Context, orgName string) (string, error) {\n\tif orgName == \"\" {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/influxdb/influxdb.go#L33-L69","documentation":"errEmptyOrganizationID is a sentinel error in the gofr InfluxDB datasource indicating that an API call requiring an organization ID was given an empty string. The library validates required identifiers up front instead of letting the InfluxDB client fail with a confusing upstream error. It is returned by DeleteOrganization and CreateBucket.","triggerScenarios":"Calling DeleteOrganization(\"\") or CreateBucket with an empty Organization field on the bucket config.","commonSituations":"Config values sourced from environment variables or flags that were never set; structs populated by JSON unmarshalling where the org id key was missing; refactored code that dropped the ID assignment.","solutions":["Set the organization ID before calling the API (e.g. cfg.OrganizationID = os.Getenv(\"INFLUX_ORG_ID\"))","Log or inspect the request struct to confirm the field is populated","Fail fast at startup if required env/config vars are empty"],"exampleFix":"// before\nsvc.DeleteOrganization(\"\")\n// after\nif orgID == \"\" {\n    return fmt.Errorf(\"org id required\")\n}\nsvc.DeleteOrganization(orgID)","handlingStrategy":"validation","validationCode":"if orgID == \"\" {\n    return errors.New(\"organization id is required\")\n}\nclient.DeleteOrganization(ctx, orgID)","typeGuard":null,"tryCatchPattern":"if err := client.DeleteOrganization(ctx, orgID); err != nil {\n    if err.Error() == \"organization id must not be empty\" {\n        // fix config / skip\n    }\n}","preventionTips":["Validate required IDs at config load time","Fail fast on empty required env vars at startup","Centralize InfluxDB calls in helpers that assert non-empty params"],"tags":["influxdb","validation","empty-identifier","gofr"],"backgroundTag":"missing-required-argument","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}