Inspect
The inspect hook allows you to retrieve metadata about a file or directory from any supported filesystem connection. This is particularly useful for validating file existence, checking file properties, or monitoring file changes.
Configuration
Properties
location
Yes
recursive
No
Whether to get total count/size nested files (true/false)
on_failure
No
What to do if the inspection fails (abort/warn/quiet/skip)
Output
When the inspect hook executes successfully, it returns the following output that can be accessed in subsequent hooks:
You can access these values in subsequent hooks using the following syntax (jmespath
):
{state.hook_id.status}
- Status of the hook execution{state.hook_id.exists}
- Whether the path exists{state.hook_id.path}
- The normalized path{state.hook_id.name}
- The name of the file/directory{state.hook_id.uri}
- The full URI{state.hook_id.is_dir}
- Whether the path is a directory{state.hook_id.size}
- Size in bytes{state.hook_id.created_at}
- Creation timestamp{state.hook_id.created_at_unix}
- Creation unix timestamp{state.hook_id.updated_at}
- Last modified timestamp{state.hook_id.updated_at_unix}
- Last modified unix timestamp
Examples
Verify File Existence (Pre-Hook)
Check if a required file exists before processing:
Check File Size (Pre-Hook)
Ensure a file is not empty before processing:
Monitor File Changes (Pre-Hook)
Track when a file was last modified:
Directory Validation (Pre-Hook)
Verify a path is a directory before processing:
File Age Check (Pre-Hook)
Skip processing if file is too old:
Notes
Not all filesystems provide all metadata fields
Timestamps may be zero if not supported by the filesystem
Directory sizes are typically reported as 0
The hook will not fail if file_path is invalid. It will simply return data as
exists: false
Last updated