AIStudio2API
AIStudio2API copied to clipboard
[Bug] UploadInlineMediaToLease fails request instead of falling back to inline media when GetAppFolder returns 401 unauthorized_client
发生了什么 / What happened
Summary
driveAuthorizationMissing explicitly matches 401 / code 16 / unauthorized_client for both GenerateAccessToken and GetAppFolder, so accounts without Google Drive authorization can still send media inline. However, UploadInlineMediaToLease only checks driveAuthorizationMissing on GenerateAccessToken's error (err), never on GetAppFolder's error (folderErr).
Trigger Path
- An account without Google Drive OAuth authorization receives a request with inline media.
- In
UploadInlineMediaToLease:s.client.appFolder(targetCtx, targetID)(GetAppFolder) runs inlookup.Go(...)and stores its error infolderErr.s.client.GenerateAccessTokenis either skipped (token != ""fromuploader.beforeUpload) or succeeds (err == nil), whileGetAppFolderreturnsHTTP 401, code 16, unauthorized_client.
if err != nil { if driveAuthorizationMissing(err) { return rewritten, temporary, nil } ... }does not run becauseerr == nil.uploadErr := folderErrfalls through toif uploadErr != nil && (keepImages || !driveStorageQuotaExceeded(uploadErr)), cleaning up and failing the entire request instead of sending the inline media.
Root Cause Pointer
internal/aistudio/upload.go:driveAuthorizationMissing(err)checksrpcError.Method == "GenerateAccessToken" || rpcError.Method == "GetAppFolder".UploadInlineMediaToLeasechecksdriveAuthorizationMissing(err)afterlookup.Wait(), but ignoresdriveAuthorizationMissing(folderErr).
Suggested Fix
Check driveAuthorizationMissing(folderErr) right after lookup.Wait() (alongside driveAuthorizationMissing(err)), returning rewritten, temporary, nil with temporary.release = s.useInlineMedia(used) so inline media fallback behaves identically for both RPCs.
版本 / Version
v0.3.13