403 ClientError is misleading when export is too large
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先跟踪 client.export_file 和 Google::Apis::ClientError 的处理过程,查看 API 响应正文在哪里被处理。重现超大的导出响应,并验证 ClientError 是否公开 JSON 错误正文或其他可用的表示形式,同时不丢失其他 403 详细信息。
由索引模型根据 Issue 内容生成。
描述
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is your feature request related to a problem? Please describe.
My team is using the client to download files. A line like:
client.export_file(file.id, 'application/pdf', :download_dest => StringIO.new).string
Is raising a Google::Apis::ClientError with an e.inspect like:
#<Google::Apis::ClientError: Invalid request status_code: 403 header: #<HTTP::Message::Headers:0x66aececb @body_encoding=#<Encoding:UTF-8>, @request_absolute_uri=nil, @dumped=false, @request_method="GET", @reason_phrase="Forbidden", @request_uri=#<Addressable::URI:0x9a0 URI:https://www.googleapis.com/drive/v3/files/FILE_ID_HERE/export?alt=media&mimeType=application%2Fpdf>, @http_version="1.1", @body_date=nil, @is_request=false, @request_query={"alt"=>"media", "mimeType"=>"application/pdf"}, @body_size=0, @status_code=403, @body_type=nil, @chunked=false, @header_item=[["Vary", "Origin"], ["Vary", "X-Origin"], ["Content-Type", "application/json; charset=UTF-8"], ["Content-Encoding", "gzip"], ["Date", "Tue, 08 Sep 2020 18:00:04 GMT"], ["Expires", "Tue, 08 Sep 2020 18:00:04 GMT"], ["Cache-Control", "private, max-age=0"], ["X-Content-Type-Options", "nosniff"], ["X-Frame-Options", "SAMEORIGIN"], ["Content-Security-Policy", "frame-ancestors 'self'"], ["X-XSS-Protection", "1; mode=block"], ["Server", "GSE"], ["Alt-Svc", "h3-29=\":443\"; ma=2592000,h3-27=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""], ["Transfer-Encoding", "chunked"]], @body_charset=nil>>
This threw us for a real loop, because most of these requests work just fine, it was just an occasional file that consistently got a 403. We finally tested the specific file in https://developers.google.com/drive/api/v3/reference/files/export and found that the full response from the API is:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "exportSizeLimitExceeded",
"message": "This file is too large to be exported."
}
],
"code": 403,
"message": "This file is too large to be exported."
}
}
Describe the solution you'd like
It would be great to get that JSON object back in the ClientError's body field, or some other mechanism.
Describe alternatives you've considered
Right now, we're just having to assume that a 403 from this endpoint means that the file is too large. But that's not great, since https://developers.google.com/drive/api/v3/handle-errors lists a whole bunch of reasons that we might be getting a 403.
- 主要语言
- Ruby
- 星标
- 2.9k
- 派生
- 888
- 平均合并
- 8 分钟
- 30 天内合并 PR
- 242
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googleapis/google-api-ruby-client 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
googleapis/google-api-ruby-client#28001 · 5 个 reaction ·
维护者通常 1 天内回复
-
googleapis/google-api-ruby-client#27757 · 已指派 1 人 ·
维护者通常 1 天内回复
-
google-apis-core: CompositeIO does not maintain the IO read contract可能已有人在做 @torreypayne 于 3 天前认领。 未关闭
googleapis/google-api-ruby-client#27758 · 已指派 1 人 ·
维护者通常 1 天内回复
-
google-apis-core: singular PagedResults ignores max可能已有人在做 @torreypayne 于 3 天前认领。 未关闭
googleapis/google-api-ruby-client#27759 · 已指派 1 人 ·
维护者通常 1 天内回复
-
api: storage type: feature request
难度 3/5 1-2 天 新手友好度 55/100
googleapis/google-api-ruby-client#27339 ·
维护者通常 1 天内回复
查看 googleapis/google-api-ruby-client 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1 小时以内 新手友好度 90/100
TheOdinProject/curriculum#31423 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
oxidize-rb/rb-sys#807 ·