This topic was automatically generated from Slack. You can find the original thread here.
I have an openAI transcription block where I’ve been getting either AxiosError code 502 or 404 errors for the last 1.5 days. It will occasionally run successfully though with no changes.
It seems like you’re encountering intermittent issues with your OpenAI transcription block, specifically receiving AxiosError codes 502 and 404. These errors indicate different issues: a 502 error typically means a Bad Gateway error, which could be due to OpenAI’s servers experiencing issues or being temporarily unavailable. A 404 error suggests that the URL you’re trying to access is not found, which could be due to an incorrect endpoint or issues on OpenAI’s end. Given the intermittent nature of the problem, it’s possible that the issue might be on OpenAI’s side, with their servers experiencing sporadic downtime or issues. Here’s a general approach to handle these errors within your Pipedream component: import { axios } from "@pipedream/platform" export default defineComponent({ props: { openai: { type: "app", app: "openai", }, }, async run({ steps, $ }) { try { return await axios($, { url: `https://api.openai.com/v1/transcriptions`, // Ensure this URL is correct method: 'post', headers: { Authorization: `Bearer ${this.openai.$auth.api_key}`, }, // Include your data payload here }) } catch (error) { if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx console.error("Data:", error.response.data); console.error("Status:", error.response.status); console.error("Headers:", error.response.headers); } else if (error.request) { // The request was made but no response was received console.error("No response received:", error.request); } else { // Something happened in setting up the request that triggered an Error console.error("Error:", error.message); } console.error("Config:", error.config); // Optionally, handle specific errors based on status code if (error.response && error.response.status === 502) { // Handle Bad Gateway error } else if (error.response && error.response.status === 404) { // Handle Not Found error } // Re-throw the error for further handling if necessary throw error; } }, }) This code includes a try...catch block to
I’m using the Pipedream “Create Transcription” block, not custom code. Is there a way to add the await axios section you have above or allow additional retries?
When using the “Create Transcription” block in Pipedream, you’re working with a pre-built action that abstracts away the need for custom code like the await axios section you mentioned. This means you cannot directly modify the action to include custom error handling or retry logic as you would in a custom code step. However, you can handle errors and implement retries in your workflow by using additional steps. Here’s a general approach: 1. Error Handling: You can use a combination of conditional steps or error workflows to handle errors that occur in the “Create Transcription” action. For example, you could add a step after the transcription action to check if the action succeeded and take appropriate action if it didn’t. 2. Retries: Implementing retries can be a bit more complex and might involve using a loop or delay actions combined with conditional logic to retry the transcription action. Unfortunately, without the ability to insert custom code directly into the “Create Transcription” action, you’ll need to build around it within the workflow to achieve similar functionality. For more advanced error handling and retry logic, you might consider using a custom code step with the axios method as you’ve described, calling the OpenAI API directly. This would give you full control over the request, including error handling and retries. Here’s a simplified example based on the error handling documentation: ```
import { axios } from “@pipedream/platform” export default defineComponent({ props: { openai: { type: “app”, app: “openai”, }, }, async run({steps, $}) { let retries = 3; for(let i = 0; i < retries; i++) { try { return await axios($, { url: https://api.openai.com/v1/audio/create, method: ‘post’, headers: { Authorization: Bearer ${this.openai.$auth.api_key}, }, data: { // Your transcription request data here } }) } catch(error) { if(i === retries - 1) throw error; // If last retry, throw error // Optionally, add a delay here before retrying } } }, })