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
The function returns raw JSON data but is annotated to return PODSIData TypedDict. The returned data should be validated or cast to ensure it matches the expected structure.
The function returns raw JSON data without validating it against the defined PODSIData type. This could lead to runtime errors if the API response doesn't match the expected structure. Consider validating the response against the defined TypedDict.
def get_lighthouse_proof(cid: str) -> PODSIData:
try:
response = requests.get(f"{Config.lighthouse_api}/api/lighthouse/get_proof?cid={cid}")
if not response.ok:
if response.status_code == 400:
raise Exception("Proof Doesn't exist yet")
raise Exception(f"Request failed with status code {response.status_code}")
data = response.json()
+ # Basic validation that the response matches our expected structure+ if "pieceCID" not in data or "dealInfo" not in data:+ raise Exception("API response doesn't match expected PODSIData structure")
return data
Apply / Chat
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that the function doesn't validate the API response against the PODSIData type hint, and adding a check improves robustness.
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
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.
User description
Description
Implemeted
podsimethodNew Features
A method to retrieve proof of data storage and integrity (PODSI) from the Lighthouse network.
PR Type
Enhancement
Description
Added PODSI method for proof of data storage and integrity
Implemented comprehensive TypedDict structures for API response
Added error handling for non-existent proofs
Diagram Walkthrough
File Walkthrough
config.py
Minor formatting fixsrc/lighthouseweb3/functions/config.py
podsi.py
Implement PODSI proof retrieval functionalitysrc/lighthouseweb3/functions/podsi.py
get_lighthouse_proof()function with CID parameter