Skip to content

Conversation

@FurkanSimsir
Copy link

Fix EachAI Workflow Execution Response Decoding

Summary

Updated EachAIWorkflowExecutionResponseBody to align with the EachAI API documentation and handle inconsistent response formats that were causing decoding failures.

Changes

Added Fields

  • parameters: [Parameter]? - Array of workflow parameters with name/value pairs

Updated Structs

  • EachAIWorkflowExecutionResponseBody: outputJson: String? field with conditional decoding
  • StepResult: outputJson: String? field with conditional decoding
  • Parameter: New struct for workflow parameters

Conditional Decoding

The EachAI API inconsistently returns output_json fields as either:

  • A plain string: "output_json": "value"
  • An array of strings: "output_json": ["value"]

Created KeyedDecodingContainer.decodeStringOrArrayIfPresent() extension to handle both formats gracefully by:

  1. Attempting to decode as String
  2. Falling back to [String] and taking the first element
  3. Returning nil if both fail

This prevents decoding failures when the API returns unexpected formats.

Files Changed

  • Sources/AIProxy/EachAI/EachAIWorkflowExecutionResponseBody.swift

@FurkanSimsir FurkanSimsir changed the title Fix decoding error and add parameters value in response Fix EachAI decoding error and add parameters value in response Nov 19, 2025
@lzell
Copy link
Owner

lzell commented Nov 19, 2025

The EachAI API inconsistently returns output_json fields as either:

A plain string: "output_json": "value"
An array of strings: "output_json": ["value"]

Interesting, thanks for reporting @FurkanSimsir ! I tagged one of the founders of EachLabs on LinkedIn, I'm seeing if we can get one of their engineers to take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants