Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Non-JSON formatted data or verbose JSON data on AudioTranscriptions couldn’t decode

Aperta
#130 2 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
swift
Ambito
api

Direzione di ricerca

Start with performRequest<ResultType: Codable>() in Sources/OpenAI/OpenAI.swift and the AudioResponseFormat enum in Sources/OpenAI/Public/Models/AudioTranscriptionQuery.swift. Check how the transcription response formats are handled and whether the same behavior applies to AudioTranslations. Done means the listed formats, including plain text and verbose JSON, can be decoded successfully.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

I have tested the behavior of new response_format parameter implemented with #114. However, my frontend code always returned a JSON decoding error.

I traced from the breakpoint and found that it catches the error at this line in the method performRequest<ResultType: Codable>() of OpenAI.swift. Errors seems to occur when anything but a specific JSON structure (e.g. plain text) is entered.

  • Serialized data is also returned as UTF-8 plain text
  • JSON structure seems to have several patterns (e.g. Verbose JSON)

I tried all formats in the new enum AudioResponseFormat and found that only .json worked fine, text, Verbose JSON, srt and vtt caught any errors.

  • ✅ AudioResponseFormat.json
  • ❌ AudioResponseFormat.text
  • ❌ AudioResponseFormat.verboseJson
  • ❌ AudioResponseFormat.srt
  • ❌ AudioResponseFormat.vtt

I have not tried testing with the AudioTranslations API, but it may contain same problems.


Error example 1

APIErrorResponse(error: OpenAI.APIError(message: "1 validation error for Request\nbody -> response_format\n value is not a valid enumeration member; permitted: 'json', 'text', 'vtt', 'srt', 'verbose_json' (type=type_error.enum; enum_values=[<ResponseFormat.JSON: 'json'>, <ResponseFormat.TEXT: 'text'>, <ResponseFormat.VTT: 'vtt'>, <ResponseFormat.SRT: 'srt'>, <ResponseFormat.VERBOSE_JSON: 'verbose_json'>])", type: "invalid_request_error", param: nil, code: nil))

Error example 2

dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character 'W' around line 1, column 1." UserInfo={NSDebugDescription=Unexpected character 'W' around line 1, column 1., NSJSONSerializationErrorIndex=0})))

Expected behavior

Correctly decode returned data as JSON or plain text (including vtt, srt).

Desktop (please complete the following information):

  • OS: macOS
  • Version 14.1.1
Lingua principale
Swift
Stelle
2.9k
Fork
519
Merge medio
4g 9h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MacPaw/OpenAI

Tutte le issue di MacPaw/OpenAI

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.