{"record":{"id":"86933d5c83299ac1","repo":"ipfs/kubo","slug":"service-already-present","errorCode":null,"errorMessage":"service already present","messagePattern":"service already present","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/pin/remotepin.go","lineNumber":510,"sourceCode":"\n\t\tif len(req.Arguments) < 3 {\n\t\t\treturn fmt.Errorf(\"expecting three arguments: service name, endpoint and key\")\n\t\t}\n\n\t\tname := req.Arguments[0]\n\t\tendpoint, err := normalizeEndpoint(req.Arguments[1])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tkey := req.Arguments[2]\n\n\t\tcfg, err := repo.Config()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif cfg.Pinning.RemoteServices != nil {\n\t\t\tif _, present := cfg.Pinning.RemoteServices[name]; present {\n\t\t\t\treturn fmt.Errorf(\"service already present\")\n\t\t\t}\n\t\t} else {\n\t\t\tcfg.Pinning.RemoteServices = map[string]config.RemotePinningService{}\n\t\t}\n\n\t\tcfg.Pinning.RemoteServices[name] = config.RemotePinningService{\n\t\t\tAPI: config.RemotePinningServiceAPI{\n\t\t\t\tEndpoint: endpoint,\n\t\t\t\tKey:      key,\n\t\t\t},\n\t\t\tPolicies: config.RemotePinningServicePolicies{},\n\t\t}\n\n\t\treturn repo.SetConfig(cfg)\n\t},\n}\n\nvar rmRemotePinServiceCmd = &cmds.Command{","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/pin/remotepin.go#L492-L528","documentation":"`ipfs pin remote add` (service registration path) refuses to add a remote pinning service whose name already exists in the node's `Pinning.RemoteServices` config map. Kubo treats service names as unique keys, so re-adding an existing name would silently overwrite its endpoint/key, and this guard prevents that. The check runs after loading the repo config, before the new service is written.","triggerScenarios":"Running `ipfs pin remote add --service=web3.storage ...` style service registration (the `pin remote add`/service-add command path) with a `name` argument that already exists under `Pinning.RemoteServices` in the repo config.","commonSituations":"Re-running an init/setup script or provisioning tool that adds a pinning service on every run without checking first; forgetting the service was already configured; trying to update an existing service's API key or endpoint by re-adding it with the same name.","solutions":["List existing services with `ipfs pin remote ls` (or inspect `Pinning.RemoteServices` in `ipfs config`) and use a different name, or skip adding if present.","If you intend to update the endpoint/key, remove the existing service first with `ipfs pin remote rm <name>`, then re-add it.","Edit the config directly to update in place: `ipfs config --json Pinning.RemoteServices.<name> '{...}'` (or use `--json` config edits) instead of re-adding.","Make automation idempotent: check existence (e.g. `ipfs pin remote ls --json` and grep the name) before calling the add command."],"exampleFix":"// before (script)\nipfs pin remote add web3.storage https://api.web3.storage/pins $KEY\n// after (idempotent)\nipfs pin remote ls | grep -q '^web3.storage ' || \\\n  ipfs pin remote add web3.storage https://api.web3.storage/pins $KEY","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nif ipfs pin remote ls 2>/dev/null | grep -q \"^${NAME} \"; then\n  echo \"service ${NAME} already registered\"\n  exit 0\nfi\nipfs pin remote add \"${NAME}\" \"${ENDPOINT}\" --key=\"${KEY}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make service-registration scripts idempotent by checking existence first","Prefer `ipfs config --json Pinning.RemoteServices.<name>` updates over add/remove cycles","Centralize service names in one provisioning script so they are added exactly once","Log the existing config before attempting to add a service"],"tags":["cli","config","remote-pinning","duplicate-key"],"backgroundTag":"duplicate-resource-conflict","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}