Why Can't I See Any Data in the "Exports" Section Despite Successful Code Execution in My Workflow?

This topic was automatically generated from Slack. You can find the original thread here.

I’ve encountered an issue with my workflow where, despite successful execution of my code steps, I’m unable to see any data under the “Exports” section of the execution details.
Key Points:

  1. I’ve tried extracting content using a code step in my workflow, but no data is appearing in the “Exports” section.
  2. The code does reach the return statement, as confirmed by using console.log statements. These logs appear correctly under the “Logs” section.
  3. I’ve attempted to simplify the code to just return a basic object to eliminate the possibility of a logic error, but still, the “Exports” section remains empty.
  4. The execution of the code step is marked as successful, and there’s no indication of errors.
  5. This behavior is consistent, and I’ve tried multiple variations of the code.
    Ask:
    I’d appreciate any insights you might have into why the exports are not appearing as expected. Is this a known issue or is there a specific configuration or setting that I might be missing?

are you able to share the specific code or would you like to share it privately with our Support team?

I think it’s fine to share. It’s parsing code:

async (event, steps) => {
  console.log("Starting parsing...");

  const gptOutput = steps.chat_suggest.result;

  console.log("GPT Output:", gptOutput);

  // Define regex patterns for each section
  const discrepanciesPattern = /Discrepancies:\s**([\s\S]**?)(?=Suggestion:|$)/;
  const suggestionPattern = /Suggestion:\s**([\s\S]**?)(?=Example:|$)/;
  const examplePattern = /Example:\s**([\s\S]**)/;

  // Extract information
  const discrepancies = (gptOutput.match(discrepanciesPattern) || [])[1]?.trim();
  const suggestion = (gptOutput.match(suggestionPattern) || [])[1]?.trim();
  const example = (gptOutput.match(examplePattern) || [])[1]?.trim();

  console.log('Discrepancies:', discrepancies);
  console.log('Suggestion:', suggestion);
  console.log('Example:', example);

  return {
    'Discrepancies': discrepancies,
    'Suggestion': suggestion,
    'Example': example
  };
}

Is that the full code in the code step? You’ll need to convert that to a Pipedream component. can you put the code in the message above into the run method of a component?

Yes, I can help you convert the code you provided into a Pipedream component. Here’s the updated code with the parsing logic placed within the run method of a Pipedream component: ```
export default defineComponent({ async run({ event, steps }) { console.log(“Starting parsing…”); const gptOutput = steps.chat_suggest.result; console.log(“GPT Output:”, gptOutput); // Define regex patterns for each section const discrepanciesPattern = /Discrepancies:\s**([\s\S]?)(?=Suggestion:|$)/; const suggestionPattern = /Suggestion:\s([\s\S]?)(?=Example:|$)/; const examplePattern = /Example:\s([\s\S]**)/; // Extract information const discrepancies = (gptOutput.match(discrepanciesPattern) || [])[1]?.trim(); const suggestion = (gptOutput.match(suggestionPattern) || [])[1]?.trim(); const example = (gptOutput.match(examplePattern) || [])[1]?.trim(); console.log(‘Discrepancies:’, discrepancies); console.log(‘Suggestion:’, suggestion); console.log(‘Example:’, example); return { ‘Discrepancies’: discrepancies, ‘Suggestion’: suggestion, ‘Example’: example }; }, });

I’m receiving this error:

TypeError
Cannot read properties of undefined (reading 'match')

DETAILS
    at Object.run (file:///tmp/__pdg__/dist/code/66c1025e7ded4030261076765edc7513a5a97c7e68ce48a51e89e0787d02e130/component.mjs:15:38)
    at null.executeComponent (/var/task/launch_worker.js:229:53)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

I apologize for the confusion earlier. It seems like the error is caused by the gptOutput variable being undefined. To fix this issue, you should ensure that the steps.chat_suggest.result value is properly defined and accessible in your workflow. Here’s the updated code with a check for gptOutput: export default defineComponent({ async run({ event, steps }) { console.log("Starting parsing..."); const gptOutput = steps.chat_suggest?.result; if (!gptOutput) { console.log("GPT Output is undefined. Please check the chat_suggest step."); return; } console.log("GPT Output:", gptOutput); // Define regex patterns for each section const discrepanciesPattern = /Discrepancies:\s**([\s\S]**?)(?=Suggestion:|$)/; const suggestionPattern = /Suggestion:\s**([\s\S]**?)(?=Example:|$)/; const examplePattern = /Example:\s**([\s\S]**)/; // Extract information const discrepancies = (gptOutput.match(discrepanciesPattern) || [])[1]?.trim(); const suggestion = (gptOutput.match(suggestionPattern) || [])[1]?.trim(); const example = (gptOutput.match(examplePattern) || [])[1]?.trim(); console.log('Discrepancies:', discrepancies); console.log('Suggestion:', suggestion); console.log('Example:', example); return { 'Discrepancies': discrepancies, 'Suggestion': suggestion, 'Example': example }; }, }); Please replace your existing code with this updated version and ensure that the steps.chat_suggest.result value is properly defined in your workflow. If you still encounter issues, please let me know.