Skip to content

getFile: return proper type#1267

Merged
alexcos20 merged 3 commits intomainfrom
bug/fix_getFile
Mar 18, 2026
Merged

getFile: return proper type#1267
alexcos20 merged 3 commits intomainfrom
bug/fix_getFile

Conversation

@alexcos20
Copy link
Member

Changes proposed in this PR:

  • use StorageObject as return for getFile function

@alexcos20
Copy link
Member Author

/run-security-scan

Copy link
Member Author

@alexcos20 alexcos20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI automated code review (Gemini 3).

Overall risk: low

Summary:
This pull request refactors the file handling and checksum retrieval logic within the compute component and utils/file.ts. It introduces a new Storage abstraction to uniformly handle different file types (URL, Arweave, IPFS) when fetching file metadata and checksums. The changes simplify the getAlgoChecksums function by delegating specific file metadata fetching to the new Storage class and standardizes the return type of getFile to StorageObject[]. This refactoring aims to improve code readability, maintainability, and potentially fix underlying issues related to file metadata handling identified in the bug ticket.

Comments:
• [INFO][style] This change effectively abstracts the logic for fetching file metadata and checksums into the Storage class. This is a significant improvement for maintainability and reduces duplication. Ensure that the Storage.getStorageClass and storage.fetchSpecificFileMetadata methods are thoroughly tested for all supported StorageObject types (Url, Arweave, Ipfs) to prevent regressions.
• [WARNING][bug] The fileInfo.checksum ?? '' handles cases where checksum might be null or undefined. While this prevents runtime errors, please confirm if an empty string '' is an acceptable value for a content checksum in all scenarios, especially if the checksum is critical for data integrity validation. Ideally, fetchSpecificFileMetadata should either guarantee a non-empty checksum when forceChecksum is true, or propagate an error if it cannot be obtained.
• [INFO][style] Changing the return type of getFile to Promise<StorageObject[]> standardizes the output and aligns it with the new Storage abstraction. This improves type safety and simplifies downstream consumers of this function.

@alexcos20
Copy link
Member Author

[WARNING][bug] The fileInfo.checksum ?? '' handles cases where checksum might be null or undefined. While this prevents runtime errors, please confirm if an empty string '' is an acceptable value for a content checksum in all scenarios, especially if the checksum is critical for data integrity validation. Ideally, fetchSpecificFileMetadata should either guarantee a non-empty checksum when forceChecksum is true, or propagate an error if it cannot be obtained.

Fixed in 5c5dc77

@alexcos20 alexcos20 merged commit 2d32d8e into main Mar 18, 2026
32 of 35 checks passed
@alexcos20 alexcos20 deleted the bug/fix_getFile branch March 18, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants