{"record":{"id":"00dc6c621b6290b1","repo":"jenkinsci/jenkins","slug":"failed-to-create-a-temp-file-on-remote","errorCode":null,"errorMessage":"Failed to create a temp file on ${remote}","messagePattern":"Failed to create a temp file on (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/FilePath.java","lineNumber":1584,"sourceCode":"\n    /**\n     * Creates a temporary file in the directory that this {@link FilePath} object designates.\n     *\n     * @param prefix\n     *      The prefix string to be used in generating the file's name; must be\n     *      at least three characters long\n     * @param suffix\n     *      The suffix string to be used in generating the file's name; may be\n     *      null, in which case the suffix \".tmp\" will be used\n     * @return\n     *      The new FilePath pointing to the temporary file\n     * @see File#createTempFile(String, String)\n     */\n    public FilePath createTempFile(final String prefix, final String suffix) throws IOException, InterruptedException {\n        try {\n            return new FilePath(this, act(new CreateTempFile(prefix, suffix)));\n        } catch (IOException e) {\n            throw new IOException(\"Failed to create a temp file on \" + remote, e);\n        }\n    }\n\n    private static class CreateTempFile extends MasterToSlaveFileCallable<String> {\n        private final String prefix;\n        private final String suffix;\n\n        CreateTempFile(String prefix, String suffix) {\n            this.prefix = prefix;\n            this.suffix = suffix;\n        }\n\n        private static final long serialVersionUID = 1L;\n\n        @Override\n        public String invoke(File dir, VirtualChannel channel) throws IOException {\n            File f = File.createTempFile(prefix, suffix, dir);\n            return f.getName();","sourceCodeStart":1566,"sourceCodeEnd":1602,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/FilePath.java#L1566-L1602","documentation":"Thrown by FilePath.createTempFile wrapping any IOException from the remote CreateTempFile callable (which calls File.createTempFile). The message names the remote path so you know which machine/directory failed. Prefix/suffix validation failures and disk/permission errors surface here.","triggerScenarios":"prefix shorter than 3 characters (File.createTempFile requirement); prefix/suffix contain path separators; directory does not exist or is not writable; disk full; too many open files.","commonSituations":"Passing a short prefix; agent tmp dir full or read-only; workspace on a full volume; concurrent temp-file exhaustion.","solutions":["Ensure prefix is at least 3 characters and contains no path separators.","Verify the target directory (this FilePath) exists and is writable on the agent.","Free disk space on the agent's relevant volume.","Pass a valid suffix or null (defaults to .tmp)."],"exampleFix":"// before\nfp.createTempFile(\"a\", \".txt\"); // prefix too short\n// after\nfp.createTempFile(\"prefix\", \".txt\");","handlingStrategy":"validation","validationCode":"if (prefix == null || prefix.length() < 3 || prefix.contains(\"/\") || prefix.contains(\"\\\\\")) {\n    throw new IllegalArgumentException(\"invalid temp file prefix: \" + prefix);\n}","typeGuard":"static boolean isValidTempPrefix(String p) {\n    return p != null && p.length() >= 3 && !p.contains(\"/\") && !p.contains(\"\\\\\");\n}","tryCatchPattern":"try {\n    FilePath tmp = fp.createTempFile(prefix, suffix);\n} catch (IOException e) {\n    // 'Failed to create a temp file' — check disk space, perms, prefix validity\n}","preventionTips":["Use prefixes of at least 3 characters with no path separators.","Ensure the target directory is writable and not full.","Pass null suffix to accept the .tmp default safely."],"tags":["temp-file","filesystem","agent"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}