{"record":{"id":"19c70db552c80ffa","repo":"opf/openproject","slug":"failed-to-create-custom-field-name-message","errorCode":null,"errorMessage":"Failed to create custom field '%{name}': %{message}","messagePattern":"Failed to create custom field '%(.+?)': %(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"app/workers/import/jira_import_projects_job/jira_import_custom_fields.rb","lineNumber":347,"sourceCode":"          end\n          return existing_cf\n        end\n        create_custom_field(jira_field, builder)\n      end\n\n      def create_custom_field(jira_field, builder)\n        name, field_format = builder.custom_field_settings\n        params = {\n          type: \"WorkPackageCustomField\",\n          name:,\n          field_format:,\n          is_required: false,\n          is_for_all: false,\n          **builder.custom_field_parameters\n        }\n        service_call = CustomFields::CreateService.new(user: @system_user).call(**params)\n        unless service_call.success?\n          raise I18n.t(\n            \"admin.jira.errors.custom_field_creation_failed\",\n            name: jira_field.payload[\"name\"],\n            message: service_call.message\n          )\n        end\n\n        custom_field = service_call.result\n        create_reference!(op_leg: custom_field, jira_leg: jira_field, jira_import: @jira_import, uses_existing: false)\n        builder.custom_field_post_processing(custom_field)\n        custom_field\n      end\n\n      # Picks the context entry whose (projects, issuetypes) match the issue's project key and\n      # issue type id. Falls back to the first context if none matches - which can happen when\n      # editmeta did not see the field for this (project, issuetype) pair but the issue still\n      # carries a value for it (e.g. the field was removed from the screen after the value was\n      # set). Falling back keeps the value rather than dropping it silently.\n      def find_context_for_issue(entry, jira_issue)","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/opf/openproject/blob/d9742c43f3424c34b63550f8c03f201fe5c3040c/app/workers/import/jira_import_projects_job/jira_import_custom_fields.rb#L329-L365","documentation":"During a Jira import run, each new Jira custom field is created through CustomFields::CreateService (type WorkPackageCustomField with a format chosen by the builder). When the ServiceResult is not successful, the job raises the interpolated admin.jira.errors.custom_field_creation_failed message, embedding the service's own validation message. The import run aborts at that field.","triggerScenarios":"A Jira field whose name is already taken by an existing OpenProject custom field, exceeds the name length limit, or whose derived field_format fails validation — e.g. importing twice, or a Jira field name longer than the local column limit.","commonSituations":"Re-running an import after a partial first run that already created some custom fields; very long Jira field names (custom field labels with prefixes); two Jira fields whose sanitized names collapse to the same custom field name.","solutions":["Read the %{message} portion of the error — it is the exact validation failure (e.g. 'Name has already been taken') and names the field via %{name}.","If a name collides, rename either the existing OpenProject custom field or the Jira field, then Retry the run.","If the name is too long, shorten the Jira field label and re-run.","For a half-completed previous run, revert it first so stale references are cleaned up."],"exampleFix":"# before\nservice_call = CustomFields::CreateService.new(user: @system_user).call(**params)\n\n# after (skip when an equally-named field already exists)\nexisting = CustomField.find_by(name: params[:name])\nservice_call = existing ? ServiceResult.success(result: existing) : CustomFields::CreateService.new(user: @system_user).call(**params)","handlingStrategy":"try-catch","validationCode":"if CustomField.exists?(name: params[:name])\n  Rails.logger.warn \"Skipping existing custom field #{params[:name]}\"\nend","typeGuard":null,"tryCatchPattern":"begin\n  create_custom_field(jira_field, builder)\nrescue StandardError => e\n  raise unless e.message.start_with?(I18n.t('admin.jira.errors.custom_field_creation_failed', name: '', message: ''))\n  record_skipped_field(e.message)\nend","preventionTips":["Diff Jira field names against existing custom field names before starting the run.","Make field creation idempotent: match on name and reuse instead of blindly creating.","Keep the underlying service message in logs — the nested validation text names the exact constraint."],"tags":["jira-import","custom-fields","validation","import-mapping"],"backgroundTag":"record-validation-failed","analyzedSha":"d9742c43f3424c34b63550f8c03f201fe5c3040c","analyzedAt":"2026-08-21T14:40:06.829Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}