{"record":{"id":"e2f10cdab2f3bbf1","repo":"can1357/oh-my-pi","slug":"source-has-invalid-access-or-modification-time-0","errorCode":null,"errorMessage":"Source has invalid access or modification time: {0}","messagePattern":"Source has invalid access or modification time: (.+?)","errorType":"error_code","errorClass":"TouchError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/touch.rs","lineNumber":43,"sourceCode":"use libc::O_NONBLOCK;\n#[cfg(unix)]\nuse rustix::fs::Timestamps;\n#[cfg(unix)]\nuse rustix::fs::futimens;\n#[cfg(target_os = \"linux\")]\nuse uucore::libc;\nuse uucore::{display::Quotable, parser::shortcut_value_parser::ShortcutValueParser};\n\nuse brush_core::{ShellExtensions, builtins::Registration};\nuse thiserror::Error as ThisError;\n\nuse crate::host::{Host, Utility, format_usage, matches_parser, util};\n\n#[derive(Debug, ThisError)]\nenum TouchError {\n\t#[error(\"Unable to parse date: {0}\")]\n\tInvalidDateFormat(String),\n\t#[error(\"Source has invalid access or modification time: {0}\")]\n\tInvalidFiletime(FileTime),\n\t#[error(\"failed to get attributes of {}: {}\", .0.quote(), io_error(.1))]\n\tReferenceFileInaccessible(PathBuf, std::io::Error),\n\t#[cfg(windows)]\n\t#[error(\"GetFinalPathNameByHandleW failed with code {0}\")]\n\tWindowsStdoutPathError(String),\n\t#[error(\"{0}\")]\n\tMessage(String),\n}\n\nfn io_error(error: &std::io::Error) -> String {\n\tif error.raw_os_error().is_some() {\n\t\tmatch error.kind() {\n\t\t\tErrorKind::NotFound => \"No such file or directory\".into(),\n\t\t\tErrorKind::PermissionDenied => \"Permission denied\".into(),\n\t\t\tErrorKind::AlreadyExists => \"Already exists\".into(),\n\t\t\tErrorKind::WouldBlock => \"Would block\".into(),\n\t\t\t_ => error.to_string().split(\" (os error \").next().unwrap_or_default().into(),","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/touch.rs#L25-L61","documentation":"This touch builtin error (crates/pi-builtins/src/touch.rs, InvalidFiletime) means the reference file's access or modification timestamp, retrieved for -r/--reference mode, is out of range or otherwise invalid when converted to the internal FileTime representation. Touch cannot propagate a timestamp it cannot represent. The offending value is included in the message.","triggerScenarios":"Running `touch -r <reference> <target>` where the reference file's stored mtime/atime is outside the representable range (e.g. extreme values on FAT/extreme epoch timestamps) or was corrupted.","commonSituations":"Reference files on FAT/exFAT filesystems with timestamps far outside normal ranges; archives containing malformed timestamps; clock-skew or year-1601/9999 edge values copied from other systems.","solutions":["Choose a different reference file with a sane timestamp (`stat <file>` to inspect).","Instead of -r, set the time explicitly: `touch -d '<timestamp>' target`.","Normalize the reference file's time first (`touch reference`) if its timestamp is corrupt.","Copy the file to a normal filesystem and use the copy as reference."],"exampleFix":"// before\ntouch -r /mnt/fat/oddfile target.txt  // Source has invalid access or modification time\n\n// after\ntouch -d '2026-01-01 00:00:00' target.txt","handlingStrategy":"fallback","validationCode":"import { statSync } from 'node:fs';\nfunction referenceTimeIsSane(p) {\n  const t = statSync(p).mtimeMs;\n  return Number.isFinite(t) && t > 0 && t < Date.now() + 3.15e12;\n}","typeGuard":"function isInvalidFiletimeError(err) {\n  return err instanceof Error && err.message.startsWith('Source has invalid access or modification time: ');\n}","tryCatchPattern":"try {\n  await touch.run(['-r', ref, target]);\n} catch (err) {\n  if (String(err).startsWith('Source has invalid access or modification time')) {\n    // fall back to copying the reference's mtime explicitly\n    const { mtime } = statSync(ref);\n    await utimes(target, mtime, mtime).catch(() => {});\n  } else throw err;\n}","preventionTips":["Inspect the reference file's timestamps (stat) before using -r.","Avoid reference files on FAT/exFAT with out-of-range timestamps.","Prefer explicit -d timestamps when the reference's provenance is unknown."],"tags":["touch","timestamps","filetime","reference"],"backgroundTag":"invalid-file-timestamp","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}