{"record":{"id":"2a89bc5b85193ca8","repo":"cube-js/cube","slug":"unexpected-output-parameter-value-payload-outpu","errorCode":null,"errorMessage":"Unexpected output parameter value '${payload.output}'","messagePattern":"Unexpected output parameter value '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-api-gateway/src/gateway.ts","lineNumber":1787,"sourceCode":"      ...query,\n      timeDimensions: query.timeDimensions || [],\n      contextSymbols: {\n        securityContext: this.securityContextExtractor(context),\n      },\n      requestId: context.requestId\n    };\n  }\n\n  protected async convertQuery({ payload, context, res }: QueryConvertRequest) {\n    try {\n      await this.assertApiScope('sql', context.securityContext);\n\n      if (payload.input !== 'sql') {\n        throw new Error(`Unexpected input parameter value '${payload.input}'`);\n      }\n\n      if (payload.output !== 'rest') {\n        throw new Error(`Unexpected output parameter value '${payload.output}'`);\n      }\n\n      if (typeof payload.query !== 'string' || !payload.query.trim()) {\n        throw new Error('query parameter must be a non-empty string');\n      }\n\n      const result = await this.sqlServer.rest4sql(payload.query, context.securityContext);\n\n      await res(result);\n    } catch (e: any) {\n      this.handleError({\n        e,\n        context,\n        query: payload,\n        res,\n      });\n    }\n  }","sourceCodeStart":1769,"sourceCodeEnd":1805,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-api-gateway/src/gateway.ts#L1769-L1805","documentation":"The /v1/convert endpoint only supports `output: 'rest'` (a SQL string converted to a Cube REST/JSON query). convertQuery throws this Error when the `output` parameter is anything else. Like the input check, it guards the single supported conversion direction.","triggerScenarios":"POST /cubejs-api/v1/convert with body { input: 'sql', output: 'sql' | 'graphql' | 'json' | anything other than 'rest', query: 'SELECT ...' }.","commonSituations":"Assuming the endpoint can convert REST -> SQL as well (it cannot); passing output mirroring input ('sql' -> 'sql'); IDE extensions or tools generating a wrong default output field.","solutions":["Set `output` to exactly 'rest' in the request body.","Remember the endpoint's sole purpose is SQL -> REST query conversion; for the reverse direction use the /v1/sql endpoint instead.","Check for typos/casing: the accepted literal is lowercase 'rest'."],"exampleFix":"// before\n{ input: 'sql', output: 'sql', query: 'SELECT count(*) FROM orders' }\n// after\n{ input: 'sql', output: 'rest', query: 'SELECT count(*) FROM orders' }","handlingStrategy":"validation","validationCode":"if (body.output !== 'rest') throw new Error(`/v1/convert requires output:'rest', got ${JSON.stringify(body.output)}`);","typeGuard":"function isConvertOutput(v: unknown): v is 'rest' { return v === 'rest'; }","tryCatchPattern":"try {\n  return await convertEndpoint(body);\n} catch (e) {\n  if (String(e?.message).startsWith('Unexpected output parameter')) {\n    return await convertEndpoint({ ...body, output: 'rest' });\n  }\n  throw e;\n}","preventionTips":["Use a typed helper wrapping /v1/convert that hardcodes output:'rest'.","Do not mirror the input value into output.","For REST->SQL conversion use the /v1/sql endpoint instead."],"tags":["rest-api","parameter-validation","sql-api"],"backgroundTag":"invalid-argument-value","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}