You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upload the file to the Keeper record using Java/Kotlin SDK causes exception "null cannot be cast to non-null type com.keepersecurity.secretsManager.core.FileRef"
#698
Open
tszielin opened this issue
Jan 3, 2025
· 2 comments
Cannot upload the file to the Keeper's record using Java/Kotlin SDK
Steps to reproduce:
create the empty "file" record in Keeper.
run an example from the documentation page Upload a File Attachment with set the UID to created empty record in code // create a filter with the UID of the record we want List<String> uidFilter = List.of("XXX");
The application throws an error null cannot be cast to non-null type com.keepersecurity.secretsManager.core.FileRef and no file is appended to record.
The text was updated successfully, but these errors were encountered:
Hello @tszielin
This is interesting bug. For now you will need to make ensure record has FileRef field initialized with the following code, before SecretsManager.uploadFile() call add following:
if (ownerRecord.getData().getField(FileRef.class) == null) {
// Initialize FileRef with empty list if it doesn't existFileReffileRef = newFileRef(newArrayList<>());
ownerRecord.getData().getFields().add(fileRef);
}
This quick hack should fix it. We will update our SDK to handle this case in the next release.
Replace unsafe cast (as T) with safe cast operator (as? T) in getField()
to prevent NPE when uploading files to records without FileRef field.
This fixes an issue where attempting to upload a file to a record
without an initialized FileRef field would throw:
"null cannot be cast to non-null type FileRef"
Fixes#698
Cannot upload the file to the Keeper's record using Java/Kotlin SDK
Steps to reproduce:
// create a filter with the UID of the record we want
List<String> uidFilter = List.of("XXX");
The application throws an error null cannot be cast to non-null type com.keepersecurity.secretsManager.core.FileRef and no file is appended to record.
The text was updated successfully, but these errors were encountered: