{"record":{"id":"65d2c0660cdb0c08","repo":"ToolJet/ToolJet","slug":"query-could-not-be-completed-65d2c0","errorCode":null,"errorMessage":"Query could not be completed","messagePattern":"Query could not be completed","errorType":"exception","errorClass":"QueryError","httpStatus":null,"severity":"error","filePath":"marketplace/plugins/fedex/lib/index.ts","lineNumber":115,"sourceCode":"      formData['child_key'] = child_key;\n      formData['child_secret'] = child_secret;\n    } else if (customer_type === CustomerType.PROPRIETARY_PARENT_CHILD) {\n      // Proprietary Parent-Child Customers flow\n      formData['grant_type'] = 'client_pc_credentials';\n      formData['child_key'] = child_key;\n      formData['child_secret'] = child_secret;\n    }\n\n    try {\n      const response = await got.post(tokenUrl, {\n        form: formData,\n        responseType: 'json',\n      });\n\n      const data = response.body as any;\n\n      if (!data.access_token) {\n        throw new QueryError('Query could not be completed', 'Access token missing in response', {\n          status: response.statusCode,\n          statusMessage: response.statusMessage,\n          errors: data,\n        });\n      }\n\n      return {\n        accessToken: data.access_token,\n        expiresIn: data.expires_in,\n      };\n    } catch (error) {\n      if (error instanceof QueryError) {\n        throw error;\n      }\n\n      throw this.parseHttpError(error, 'Failed to obtain OAuth token from FedEx');\n    }\n  }","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/marketplace/plugins/fedex/lib/index.ts#L97-L133","documentation":"Thrown by Fedex.generateOAuthToken after a successful HTTP call to ${base_url}/oauth/token whose JSON body lacks an access_token field. FedEx returned a 2xx response but the body did not contain a usable token, so the plugin refuses to proceed. The error's `.data` carries the statusCode, statusMessage, and the full response body (`errors`) for diagnosis.","triggerScenarios":"FedEx returns 200 with a body like {\"error\":\"invalid_client\"} and no access_token; client_id/client_secret are well-formed but revoked or disabled; grant_type does not match the customer_type configured in FedEx Developer Console; sandbox credentials sent to the production base_url.","commonSituations":"Credentials disabled or rotated in the FedEx Developer Console after initial setup; customer_type changed in the datasource but the OAuth client in FedEx was not reconfigured; environment drift between sandbox and production credentials.","solutions":["Inspect err.data.errors to read FedEx's actual reason from the response body.","Verify client_id and client_secret are still active in the FedEx Developer Console for the target environment.","Ensure the customer_type selection matches the OAuth client type configured in FedEx (standard vs internal vs proprietary parent-child).","Confirm base_url matches the environment the credentials were issued for (sandbox vs production).","Re-issue credentials in the FedEx Developer Console if they were revoked, then re-run the query."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate that credentials are plausible before letting generateOAuthToken call FedEx.\nfunction assertFedexCreds(s: SourceOptions) {\n  if (!s.client_id || !s.client_secret) throw new Error('FedEx client_id/client_secret required');\n  if (s.customer_type && s.customer_type !== 'standard_customers' && (!s.child_key || !s.child_secret)) {\n    throw new Error('child_key/child_secret required for ' + s.customer_type);\n  }\n}\nawait assertFedexCreds(sourceOptions);","typeGuard":"function hasAccessToken(body: unknown): body is { access_token: string } {\n  return typeof (body as any)?.access_token === 'string' && (body as any).access_token.length > 0;\n}\n// if (!hasAccessToken(data)) { /* handle before the plugin throws */ }","tryCatchPattern":"try {\n  await fedex.run(sourceOptions, queryOptions, dataSourceId);\n} catch (err) {\n  if (err?.data?.errors) console.error('FedEx token error body:', err.data.errors);\n  throw err;\n}","preventionTips":["Keep credentials active in the FedEx Developer Console; rotate before expiry.","Match customer_type to the OAuth client type configured in FedEx.","Use sandbox credentials only with the sandbox base_url.","Log err.data.errors to capture FedEx's exact rejection reason."],"tags":["fedex","oauth","authentication","token","typescript"],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}