Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/google-picker-response-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@uppy/core": patch
---

Validate Google Picker responses before importing them. `@types/google.picker`
v0.0.52 correctly types `docs`, `name` and `mimeType` as optional, so the picker
now throws a descriptive error instead of importing a file with an undefined
name or mime type. Shortcut metadata on the picked document is preserved.
10 changes: 8 additions & 2 deletions examples/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
Expand All @@ -22,6 +22,12 @@
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": ["node_modules"]
}
6 changes: 3 additions & 3 deletions examples/reactrouter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@mjackson/file-storage": "^0.7.0",
"@mjackson/form-data-parser": "^0.9.1",
"@react-router/express": "^7.12.0",
"@react-router/express": "^7.18.1",
"@tus/file-store": "latest",
"@tus/server": "latest",
"@uppy/core": "workspace:*",
Expand All @@ -23,10 +23,10 @@
"express": "^5.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^7.12.0"
"react-router": "^7.18.1"
},
"devDependencies": {
"@react-router/dev": "^7.12.0",
"@react-router/dev": "^7.18.1",
"@types/express": "^5.0.6",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@uppy/core": "workspace:^",
"@vitest/browser-playwright": "^4.1.6",
"jsdom": "^29.1.1",
"nock": "^13.1.0",
"nock": "^15.0.0",
"playwright": "1.61.1",
"typescript": "^6.0.3",
"vitest": "^4.1.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/companion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"@types/ws": "8.18.1",
"execa": "10.0.0",
"http-proxy": "1.18.1",
"nock": "^14.0.15",
"nock": "^15.0.0",
"supertest": "7.2.2",
"typescript": "^6.0.3",
"vitest": "4.1.6"
Expand Down
7 changes: 5 additions & 2 deletions packages/@uppy/companion/test/credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ describe('providers requests with remote oauth keys', () => {
// mocking request module used to fetch custom oauth credentials
nock('http://localhost:2111')
.post('/zoom-keys')
// @ts-expect-error
.reply((uri, { provider, parameters }) => {
.reply(async (request) => {
const { provider, parameters } = (await request.json()) as {
provider?: string
parameters?: string
}
if (provider !== 'zoom' || parameters !== 'ZOOM-CREDENTIALS-PARAMS')
return [400]

Expand Down
5 changes: 2 additions & 3 deletions packages/@uppy/companion/test/fixtures/zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ export const nockZoomRevoke = ({
}) => {
nock('https://zoom.us')
.post('/oauth/revoke?token=token+value')
.reply(function () {
const { headers } = this.req
.reply((request) => {
const expected = getBasicAuthHeader(key, secret)
const success = headers['authorization'] === expected
const success = request.headers.get('authorization') === expected
return success ? [200, { status: 'success' }] : [400]
})
}
4 changes: 2 additions & 2 deletions packages/@uppy/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"devDependencies": {
"@types/deep-freeze": "^0",
"@types/gapi": "^0.0.47",
"@types/google.accounts": "^0.0.14",
"@types/google.picker": "^0.0.42",
"@types/google.accounts": "^0.0.18",
"@types/google.picker": "^0.0.52",
"@types/lodash": "^4.14.199",
"@types/node": "^20.19.0",
"cssnano": "^8.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,28 @@ export async function showDrivePicker({
try {
onLoadingChange(true)

if (!picked.docs) {
throw new Error('Google Picker returned no selected documents')
}

const results: PickedDriveItem[] = []
for (const doc of picked.docs) {
if (!doc.name || !doc.mimeType) {
throw new Error(

@mifi mifi Jul 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not throw, we should probably update the returned types accordingly: https://developers.google.com/workspace/drive/picker/reference/picker.documentobject.mimetype

`Google Picker returned an incomplete document (${doc.id})`,
)
}
results.push(
...(await handleDocObjectRecursively({ doc, token, signal })),
...(await handleDocObjectRecursively({
doc: {
...doc,
id: doc.id,
name: doc.name,
mimeType: doc.mimeType,
},
token,
signal,
})),
)
}
onFilesPicked(results, token)
Expand Down
Loading