Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ export function apiResponseError (status: number, body: unknown, headers: Header
hint: 'This request was rejected without starting a test. Run `poki limits get` for current capacity. Reduce the recording batch if it can fit, wait for quota to reset or be released, or contact your account manager if the limit is zero. Do not automatically retry or cancel work to regain quota.'
})
}
if (status === 409 && request.method === 'POST' && /^\/games\/[^/]+\/marketing_assets\/[^/]+$/.test(request.path) && firstErrorTitle === 'game must be approved') {
return new CliError(code, message, 4, {
status,
details: safeDetails,
retryable: false,
requestId: headers.get('x-request-id') ?? undefined,
hint: 'Media Kit uploads become available once your game is approved. Inspect approved with `poki games get GAME_ID` and wait for approval before uploading again.'
})
}
const method = request.method ?? 'GET'
const retrySafe = method === 'GET' || request.retrySafe === true
const transient = status === 408 || status === 429 || status >= 500
Expand Down
3 changes: 2 additions & 1 deletion src/docs/command-groups/media-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ export function addMediaKitCommandSpecs ({ add, apiAction, argument, downloadReq
})
apiAction(['media-kit', 'upload'], 'Upload one or more files of one current asset type.', { method: 'MULTIPLE', path: [`POST ${collection}/:type`, `GET ${collection} (--wait only)`], contacts_api: true }, [edit, read], {
options: [gameOption, option('--type', 'enum', 'Current asset type; run poki media-kit types for requirements.', { values: [...mediaKitUploadTypes], required: true }), option('--file', 'path', 'Readable nonempty file; repeat once per file, up to 50.', { repeatable: true, required: true }), ...uploadMutationOptions, ...waitOptions('Poll once per interval for all newly accepted IDs to become ready.')],
permission_logic: 'Uploading requires can_edit_owned_marketing_assets; polling additionally requires can_read_owned_marketing_assets.',
permission_logic: 'Uploading requires an approved game and can_edit_owned_marketing_assets; polling additionally requires can_read_owned_marketing_assets.',
missing_input: '--type and --file',
side_effects: ['Creates assets and starts asynchronous storage uploads. Accepted files remain created when other files fail.'],
behavior: [
'Uploads require games.approved=true, including for admins. The server rejects unapproved games with 409 Conflict before processing files. Existing assets can still be read, downloaded, and deleted. Dry-run does not check game approval.',
'Uses repeated multipart file fields and streams file-backed blobs. Dry-run validates local files and describes the request without contacting the API.',
'Normalized success always returns a collection, including single-file uploads; raw output preserves the original singular or collection response.',
'Partial acceptance raises MEDIA_KIT_UPLOAD_PARTIAL_FAILURE (exit 4), with details.accepted, accepted_ids, failed [{filename, error}], and recovery commands. It returns immediately even when polling was requested. Do not replay the batch.',
Expand Down
5 changes: 5 additions & 0 deletions test/media-kit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ void test('Media Kit API rejections retain normal permission and unavailable-ass
const unavailable = await runCli(scoped('download-url', 'a'), { env })
assert.equal(unavailable.code, 4)
assert.equal(errorOf(unavailable).code, 'CONFLICT')
const approval = apiResponseError(409, { errors: [{ status: '409', code: 'conflict', title: 'game must be approved' }] }, new Headers(), { method: 'POST', path: '/games/g/marketing_assets/image_screenshot' })
assert.equal(approval.code, 'CONFLICT')
assert.equal(approval.exitCode, 4)
assert.equal(approval.retryable, false)
assert.match(approval.hint ?? '', /once your game is approved/)
})

for (const interrupt of ['signal', 'handler'] as const) {
Expand Down
Loading