Skip to content

parseDiffFromFile defaults to low-specificity cache key #1052

Closed

Description

@jonatanklosko

The docs currently say:

If both oldFile and newFile have a cacheKey, the resulting FileDiffMetadata will automatically receive a combined cache key (format: oldKey:newKey).

It would be fair to assume that if cacheKey is not set, it will not be cached. However, the current implementation defaults each file cache key to file name:

const fileData = processFile(patch, {
cacheKey: (() => {
const oldCacheKey = oldFile?.cacheKey ?? oldFile?.name;
const newCacheKey = newFile?.cacheKey ?? newFile?.name;
if (oldCacheKey != null && newCacheKey != null) {
return oldCacheKey + ':' + newCacheKey;
}
return oldCacheKey ?? newCacheKey;
})(),

Consequently, when using parseDiffFromFile for two subsequent changes of the same file, the renderer uses wrong cached information and throws:

DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong

Given the above, I think either the docs should be clarified, or there should be no cacheKey generated unless explicitly specified (safer default).

An immediate fix on the user side is to specify a more specific cacheKey on each file, such as "{file_name}:{hash(file_content)}".

Activity

  1. amadeus commented on Aug 4, 2026

    @amadeus
    Member

    Oh yeah, that was a change that slipped through with the edit feature that I ultimately never saw, i'll need to dig into this to figure out why it was changed and if it's necessary. Thanks for the callout!

  2. AbarnaaSree commented on Aug 5, 2026

    @AbarnaaSree

    I'd like to work on this. I'll investigate whether removing the filename fallback affects the edit feature and propose a fix if it doesn't.

  3. amadeus commented on Aug 5, 2026

    @amadeus
    Member

    Appreciate the offer but I’ve already started on this in #1055, it’s a bit more complicated than simply removing the lines

  4. amadeus commented on Aug 28, 2026

    @amadeus
    Member

    Fixed in the next beta release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions