fix: use a cache file name with a fixed size. #350
Merged
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.
Closes #348
📑 Description
Our current caching method creates a file with the following pattern:
$BACKEND_AI-$LANG-$SENC
SENC
corresponds to a base64 encoding of the errors detected on an object during analysis.This approach fails when we have multiple errors reported for the same object. The base64 string becomes too long, resulting in the following error:
error storing value to cache: open /Users/matthisholleville/Library/Caches/k8sgpt/openai-english-SW5ncmVzcyBrOHNncHQvZmFrZS1pbmdyZXNzIGRvZXMgbm90IHNwZWNpZnkgYW4gSW5ncmVzcyBjbGFzcy4gSW5ncmVzcyB1c2VzIHRoZSBzZXJ2aWNlIGs4c2dwdC9mYWtlLXNlcnZpY2Ugd2hpY2ggZG9lcyBub3QgZXhpc3QuIEluZ3Jlc3MgdXNlcyB0aGUgc2VjcmV0IGs4c2dwdC9mYWtlLXNlY3JldCBhcyBhIFRMUyBjZXJ0aWZpY2F0ZSB3aGljaCBkb2VzIG5vdCBleGlzdC4=: file name too long
To address this issue, we use SHA256 to encode filename and keep fixe file name size
✅ Checks
ℹ Additional Information
I have also fixed another bug related to the no-cache feature. Previously, when we activated no-cache, the cache was not used, but the command result was not updated either. This resulted in bugs like the following:
I have fixed this issue so that when the
--no-cache
option is enabled, the cache is not used, but it is updated with the latest response.