fix: multiple timestamp_granularities collapse to last value in audio endpoint

Open Beginner friendly
#211 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
api

Research direction

Start in reference-server/src/routes/audio.ts at the multipart field handling that currently overwrites repeated names. Add or update the audio endpoint test with granularities: ['word', 'segment'], then verify the response contains both words and segments arrays.

Written by the indexing model from the issue text.

Description

bug

Problem

In reference-server/src/routes/audio.ts, non-file multipart parts are stored as:

fields[part.fieldname] = { value: part.value };

This overwrites on repeated field names — last value wins. When the SDK sends timestamp_granularities as repeated form fields (e.g. ['word', 'segment']), only 'segment' is preserved.

Reported in PR #149 review.

Fix

Accumulate repeated fields into an array instead of overwriting. For example:

if (fields[part.fieldname]) {
  // Convert to array or push to existing array
  const existing = fields[part.fieldname];
  if (Array.isArray(existing)) {
    existing.push(part.value);
  } else {
    fields[part.fieldname] = [existing, part.value];
  }
} else {
  fields[part.fieldname] = { value: part.value };
}

Tests Needed

  • Add a test passing granularities: ['word', 'segment'] and assert both words and segments arrays are present in the response.
Dominant language
TypeScript
Stars
0
Forks
5
Avg merge
3d 5h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mieweb/ozwellai-api

All issues in mieweb/ozwellai-api

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.