{"record":{"id":"0cedd8d6b29285e4","repo":"theonedev/onedev","slug":"unable-to-import-build-spec-import-project-0","errorCode":null,"errorMessage":"Unable to import build spec (import project: {0}, import revision: {1}): {2}","messagePattern":"Unable to import build spec \\(import project: (.+?), import revision: (.+?)\\): (.+?)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/Import.java","lineNumber":163,"sourceCode":"\t\n\t@SuppressWarnings(\"unused\")\n\tprivate static List<String> getAccessTokenSecretChoices() {\n\t\treturn Project.get().getHierarchyJobSecrets()\n\t\t\t\t.stream().map(it->it.getName()).collect(Collectors.toList());\n\t}\n\t\n\tpublic BuildSpec getBuildSpec() {\n\t\tif (buildSpec == null) {\n\t\t\tProject project = getProject();\n\n\t\t\tSubject subject;\n\t\t\ttry {\n\t\t\t\tsubject = JobAuthorizationContext.get().getSubject(getAccessTokenSecret());\n\t\t\t} catch (ExplicitException e) {\n\t\t\t\tvar errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Unable to import build spec (import project: {0}, import revision: {1}): {2}\"),\n\t\t\t\t\t\tprojectPath, revision, e.getMessage());\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}\n\t\t\tif (!subject.isPermitted(new ProjectPermission(project, new ReadCode())) \n\t\t\t\t\t&& !project.isPermittedByLoginUser(new ReadCode())) {\n\t\t\t\tString errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Code read permission is required to import build spec (import project: {0}, import revision: {1})\"), \n\t\t\t\t\t\tprojectPath, revision);\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}\n\t\t\t\n\t\t\tRevCommit commit = getCommit();\n\t\t\ttry {\n\t\t\t\tbuildSpec = project.getBuildSpec(commit);\n\t\t\t} catch (BuildSpecParseException e) {\n\t\t\t\tString errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Malformed build spec (import project: {0}, import revision: {1})\"), \n\t\t\t\t\t\tprojectPath, revision);\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/Import.java#L145-L181","documentation":"Import.getBuildSpec loads a build spec from another project/revision on behalf of the current job subject. If creating the authorization subject from the access token fails (ExplicitException), the message is wrapped as 'Unable to import build spec (import project: X, import revision: Y): <cause>'. This indicates the import itself could not authenticate, not a permission shortfall.","triggerScenarios":"A job secret/token used for the import is invalid, expired, revoked, or empty; JobAuthorizationContext.get().getSubject(accessTokenSecret) throws ExplicitException during getBuildSpec().","commonSituations":"Referencing another project's build spec with a job token that lacks access; rotating project access tokens without updating the job secret; typos in the secret reference so the token resolves to nothing; importing from a revision that no longer exists.","solutions":["Regenerate the project access token and update the job secret used by the import","Verify the job secret name referenced in accessTokenSecret actually exists and holds a valid token","Check the import revision/branch still exists in the target project","Confirm the import project path is spelled correctly and the project exists"],"exampleFix":"// before: token secret deleted/rotated\naccessTokenSecret: old-project-token\n// after\naccessTokenSecret: project-token   # secret recreated with a live access token","handlingStrategy":"try-catch","validationCode":"// ensure the job secret referenced by accessTokenSecret exists and the token is not expired\n// (check in Project > Access Tokens before configuring the import)","typeGuard":null,"tryCatchPattern":"try {\n    BuildSpec imported = import_.getBuildSpec();\n} catch (ExplicitException e) {\n    // 'Unable to import build spec ...: <cause>' -> fix token/revision per cause\n}","preventionTips":["Rotate and update access tokens used by imports promptly","Verify secret names referenced in accessTokenSecret","Check import project path and revision exist","Test cross-project imports after permission changes"],"tags":["buildspec","import","authentication","token"],"backgroundTag":"authentication-required","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}