{"record":{"id":"cfbe7a7aa6599b79","repo":"onetimesecret/onetimesecret","slug":"duplicate-domain-for-organization","errorCode":null,"errorMessage":"Duplicate domain for organization","messagePattern":"Duplicate domain for organization","errorType":"exception","errorClass":"Onetime::Problem","httpStatus":null,"severity":"error","filePath":"lib/onetime/models/custom_domain.rb","lineNumber":883,"sourceCode":"            # it's safe even when the original failure was an org-lookup error.\n            -> {\n              obj.organization_instances.each do |o|\n                obj.remove_from_organization_domains(o)\n              end\n            },\n          ]\n          rollback_steps.each do |step|\n            step.call\n          rescue StandardError => step_ex\n            OT.le \"[CustomDomain.create!] rollback step failed for #{obj.display_domain}: #{step_ex.message}\"\n          end\n          raise ex\n        end\n\n        obj # Return the created object\n      rescue Familia::RecordExistsError => ex\n        OT.le \"[CustomDomain.create!] Duplicate domain: #{ex.message}\"\n        raise Onetime::Problem, 'Duplicate domain for organization'\n      rescue Redis::BaseError => ex\n        OT.le \"[CustomDomain.create!] Redis error: #{ex.message}\"\n        raise Onetime::Problem, 'Unable to create custom domain'\n      end\n\n      # Create default-disabled HomepageConfig and ApiConfig records for a\n      # freshly created CustomDomain. Idempotent via find_or_create_for_domain\n      # (WATCH+MULTI), so a concurrent PUT that wrote first preserves its value.\n      def bootstrap_per_domain_configs(obj)\n        Onetime::CustomDomain::HomepageConfig.find_or_create_for_domain(\n          domain_id: obj.identifier, enabled: false,\n        )\n        Onetime::CustomDomain::ApiConfig.find_or_create_for_domain(\n          domain_id: obj.identifier, enabled: false,\n        )\n      end\n\n      # Atomically claim an orphaned domain for an organization.","sourceCodeStart":865,"sourceCodeEnd":901,"githubUrl":"https://github.com/onetimesecret/onetimesecret/blob/f81295e41bc3e808a3dd2cbea03ef65401a662e4/lib/onetime/models/custom_domain.rb#L865-L901","documentation":"Error \"Duplicate domain for organization\" thrown in onetimesecret/onetimesecret.","triggerScenarios":"Thrown at lib/onetime/models/custom_domain.rb:883 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Find the existing domain record for this organization and reuse or update it instead of creating a duplicate."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f81295e41bc3e808a3dd2cbea03ef65401a662e4","analyzedAt":"2026-08-23T21:13:10.635Z","schemaVersion":2},"datasetVersion":"2026-08-24T02:17:37.098Z"}