fix(kvs): write record metadata sidecars for input files - #1416
Merged
Conversation
- Write Crawlee key-value store metadata sidecars when generating prefilled input files. - Read input files using metadata sidecars instead of guessing file extensions. - Preserve metadata sidecar files during key-value store purges. - Related to apify/crawlee#2710 (comment) - Does not break BC with crawlee 3.x and the Python version
l2ysho
reviewed
Sep 11, 2026
Comment on lines
+61
to
+71
| export function readKvsRecordMetadata(storePath: string, key: string): KvsRecordMetadata | undefined { | ||
| let metadata: KvsRecordMetadata; | ||
|
|
||
| try { | ||
| metadata = JSON.parse(readFileSync(join(storePath, recordMetadataFileName(key)), 'utf8')); | ||
| } catch { | ||
| return undefined; | ||
| } | ||
|
|
||
| return typeof metadata?.contentType === 'string' ? metadata : undefined; | ||
| } |
Contributor
There was a problem hiding this comment.
Claude bothered me with this hypothetical traversal issue, when user clone actors with malicious sidecar
{ "key": "INPUT", "contentType": "application/json; charset=utf-8",
"filename": "../../../../home/.apify/auth.json" }
Tried it now so yes it can be done. I mean it is not probably real issue but also it should not be hard to ensure filename is not a path for future proof 🤔
Resolve this as you like.
Contributor
Author
There was a problem hiding this comment.
That's 1) as contrived as it gets and 2) already validated in apify/crawlee-storage (used in crawlee v4, the only existing consumer of this option to date).
But let me add a check on the CLI side as well.
l2ysho
approved these changes
Sep 11, 2026
l2ysho
left a comment
Contributor
There was a problem hiding this comment.
nice @janbuchar
leaving one comment to you to decide 🚀
vladfrangu
approved these changes
Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Write Crawlee key-value store metadata sidecars when generating prefilled input files.
Read input files using metadata sidecars instead of guessing file extensions.
Preserve metadata sidecar files during key-value store purges.
Related to Consider avoiding adding suffixes to files in
FileSystemStorageBackendcrawlee#2710 (comment)Does not break BC with crawlee 3.x and the Python version