fix(fs): handle folder info array response#4
Merged
Conversation
Co-authored-by: OpenAI Codex <codex@openai.com>
25 tasks
There was a problem hiding this comment.
Pull request overview
This PR fixes GetFolderInfo / GetFolderInfoByPath decoding when the 115 /open/folder/get_info API returns data as an array (notably for missing path lookups), enabling callers to reliably detect “not found” vs. true JSON/schema errors.
Changes:
- Added a custom
UnmarshalJSONtoGetFolderInfoRespto accept both object and arraydatashapes, mapping an empty array toErrObjectNotFound. - Introduced
ErrObjectNotFoundas a package-level sentinel error for missing objects. - Added unit tests covering object, array, and empty-array unmarshalling for
GetFolderInfoResp.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| fs.go | Implements tolerant JSON unmarshalling for folder info responses that may be object or array. |
| error.go | Adds a reusable ErrObjectNotFound sentinel error. |
| fs_test.go | Adds tests validating the new unmarshalling behavior, including the empty-array not-found case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
25 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This fixes the root cause behind OpenListTeam/OpenList#2562.
The 115 Open
/open/folder/get_infoAPI may returndataas an array for path-based folder info lookups, especially when the requested path is missing. The SDK currently always unmarshalsdataintoGetFolderInfoResp, so callers receive:This change makes
GetFolderInfoRespaccept both shapes:ErrObjectNotFoundThis allows callers such as OpenList to distinguish missing objects from real JSON/schema failures.
Related
Testing
gofmt -w fs.go error.go fs_test.gogit diff --checkI did not run
go testlocally because the downstream OpenList task is under a local testing constraint that forbids generating compiled test artifacts/caches.AI Disclosure
This PR includes AI-assisted content.
Tools used:
Usage scope:
I reviewed and validated the AI-assisted content before submission. The commit includes
Co-authored-by: OpenAI Codex <codex@openai.com>attribution.