{"record":{"id":"631b604454b26032","repo":"apache/beam","slug":"expected-1-option-got-v-v-gcs","errorCode":null,"errorMessage":"expected 1 option, got %v: %v","messagePattern":"expected 1 option, got (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/filesystem/gcs/gcs.go","lineNumber":125,"sourceCode":"\t\t}\n\t}\n\n\tresult.WriteString(\"$\") // match end\n\treturn regexp.Compile(result.String())\n}\n\nvar billingProject string = \"\"\n\nfunc init() {\n\tfilesystem.Register(\"gs\", New)\n\thf := func(opts []string) hooks.Hook {\n\t\treturn hooks.Hook{\n\t\t\tInit: func(ctx context.Context) (context.Context, error) {\n\t\t\t\tif len(opts) == 0 {\n\t\t\t\t\treturn ctx, nil\n\t\t\t\t}\n\t\t\t\tif len(opts) > 1 {\n\t\t\t\t\treturn ctx, fmt.Errorf(\"expected 1 option, got %v: %v\", len(opts), opts)\n\t\t\t\t}\n\n\t\t\t\tbillingProject = opts[0]\n\t\t\t\treturn ctx, nil\n\t\t\t},\n\t\t}\n\t}\n\thooks.RegisterHook(projectBillingHook, hf)\n}\n\ntype fs struct {\n\tclient *storage.Client\n}\n\n// New creates a new Google Cloud Storage filesystem using application\n// default credentials. If it fails, it falls back to unauthenticated\n// access.\n// It will use the environment variable named `BILLING_PROJECT_ID` as requester payer bucket attribute.","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/gcs/gcs.go#L107-L143","documentation":"The GCS billing-project Init hook accepts at most one option (the requester-pays billing project). Passing more than one option to the hook registration triggers this error at init time, because there is exactly one billing project per filesystem configuration.","triggerScenarios":"Registering the projectBillingHook (via the hooks package / RequesterBillingProject plumbing) with two or more options in the opts slice; the hook's Init function then returns this error during startup.","commonSituations":"Accidentally accumulating options across multiple calls; passing a variadic slice with duplicates; wiring up the hook manually with a slice of several candidate projects.","solutions":["Pass exactly one billing project option (or none to skip billing-project config).","Deduplicate/trim the options slice before registering the hook.","Register RequesterBillingProject only once per pipeline.","Check for repeated hook-enable calls in shared setup code."],"exampleFix":"// before\nhooks.EnableHook(projectBillingHook, \"proj-a\", \"proj-b\") // >1 option\n// after\nhooks.EnableHook(projectBillingHook, \"proj-a\") // exactly one option","handlingStrategy":"validation","validationCode":"if len(opts) > 1 { return errors.New(\"projectBillingHook accepts at most 1 option\") }","typeGuard":null,"tryCatchPattern":"if err := hookInit(...); err != nil && strings.Contains(err.Error(), \"expected 1 option\") {\n\tlog.Fatalf(\"billing project hook misconfigured: %v\", err)\n}","preventionTips":["Call RequesterBillingProject exactly once per pipeline.","Deduplicate option slices before enabling hooks.","Keep hook wiring centralized in one setup function.","Assert len(opts) <= 1 in setup code."],"tags":["go","apache-beam","gcs","hook","config"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}