-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Description
When using gws gmail users messages get with format=metadata and metadataHeaders as an array, the array is stringified instead of being expanded into repeated query parameters.
Steps to Reproduce
gws gmail users messages get --params '{"userId":"me","id":"<msg_id>","format":"metadata","metadataHeaders":["From","Subject","Date"]}' --dry-runExpected
"query_params": {
"format": "metadata",
"metadataHeaders": ["From", "Subject", "Date"]
}With the HTTP request containing: ?format=metadata&metadataHeaders=From&metadataHeaders=Subject&metadataHeaders=Date
Actual
"query_params": {
"format": "metadata",
"metadataHeaders": "[\"From\",\"Subject\",\"Date\"]"
}The array is stringified as a single value, so the Gmail API ignores it and returns no headers.
Root Cause
gws schema gmail.users.messages.get shows metadataHeaders without repeated: true:
"metadataHeaders": {
"description": "When given and format is METADATA, only include headers specified.",
"location": "query",
"required": false,
"type": "string"
}But the Gmail Discovery Doc at https://gmail.googleapis.com/$discovery/rest?version=v1 has:
"metadataHeaders": {
"description": "When given and format is METADATA, only include headers specified.",
"location": "query",
"repeated": true,
"type": "string"
}The repeated field is being dropped when gws parses/caches the Discovery Document, so build_url() treats the array as a non-repeated param and stringifies it.
Environment
- gws v0.11.1
- macOS (arm64)
Workaround
Use format=full instead of format=metadata — returns all headers but with more data than necessary.