[PR #4604] [MERGED] fix(noodle): unwrap LLM array responses in noodler post parsing #6440

Closed
opened 2026-10-23 04:10:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4604
Author: @MetzeVanDeus
Created: 8/4/2026
Status: ✅ Merged
Merged: 8/5/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/noodler-post-array-unwrap


📝 Commits (9)

  • 685d379 fix(noodle): unwrap LLM array responses in noodler post parsing
  • 3d04607 Merge branch 'staging' into fix/noodler-post-array-unwrap
  • eadcab5 Update packages/server/src/services/noodle/noodle-noodler-generation.service.ts
  • 30e4c9a fix(noodle): remove stale array parsing branch
  • 8dea3ae Merge branch 'staging' into fix/noodler-post-array-unwrap
  • ac26cb4 Merge branch 'staging' into fix/noodler-post-array-unwrap
  • 94f34a7 Merge branch 'staging' into fix/noodler-post-array-unwrap
  • eb0f758 Merge branch 'staging' into fix/noodler-post-array-unwrap
  • 1f6dfed Merge branch 'staging' into fix/noodler-post-array-unwrap

📊 Changes

1 file changed (+7 additions, -1 deletions)

View changed files

📝 packages/server/src/services/noodle/noodle-noodler-generation.service.ts (+7 -1)

📄 Description

Many LLMs (especially local models via Ollama/KoboldCPP) wrap the expected object in an array ([{"title":...}]) regardless of the prompt instructing "one JSON object". Add a guard in parseNoodlerPost to unwrap all array cases: empty -> {}, single -> first element, multiple -> first element.

This resolves the 'expected object, received array' ZodError that occurs during Noodler post creation regardless of model, context, or retry attempts.

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #4597

Why this change

  • Noodler post creation fails with expected object, received array ZodError when LLMs (Ollama, KoboldCPP, LM Studio) return response wrapped in an array

What changed

  • Added array unwrap guard in parseNoodlerPost() — handles [] → {}, [{...}] → {...}, [{...}, {...}] → first element

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Opened app through launcher, noodle settings, manage schedules on noodler, pressed run now on one of the scheduled profiles. It successfully generated a post.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of generated responses containing a single result wrapped in an array.
    • Single-element arrays are now validated using their contained result.
    • Empty arrays, multi-element arrays, and direct object responses continue to be validated without changes.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4604 **Author:** [@MetzeVanDeus](https://github.com/MetzeVanDeus) **Created:** 8/4/2026 **Status:** ✅ Merged **Merged:** 8/5/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/noodler-post-array-unwrap` --- ### 📝 Commits (9) - [`685d379`](https://github.com/Pasta-Devs/Marinara-Engine/commit/685d379d54dada467a86abb8529dddb80061d3b9) fix(noodle): unwrap LLM array responses in noodler post parsing - [`3d04607`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3d04607e88b1f4d9c3a6d146c98c4aa874c7cb98) Merge branch 'staging' into fix/noodler-post-array-unwrap - [`eadcab5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eadcab576349837e101b14e8fe8a3a4d00696fe5) Update packages/server/src/services/noodle/noodle-noodler-generation.service.ts - [`30e4c9a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/30e4c9a8ce47c054af79ea8285e16b22ce576de0) fix(noodle): remove stale array parsing branch - [`8dea3ae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8dea3ae4d3aa7e1218c6b3815ac284d78e0244ae) Merge branch 'staging' into fix/noodler-post-array-unwrap - [`ac26cb4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ac26cb49aa27ea4764a97bf4ccde72a3e9cc2392) Merge branch 'staging' into fix/noodler-post-array-unwrap - [`94f34a7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/94f34a7a1be16736cff9cf4780ed412ec13a4225) Merge branch 'staging' into fix/noodler-post-array-unwrap - [`eb0f758`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eb0f75826495a09cd04eae291d79ce1ac7339cd5) Merge branch 'staging' into fix/noodler-post-array-unwrap - [`1f6dfed`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1f6dfedd0f9594e120c9fbca8b87da328408ec67) Merge branch 'staging' into fix/noodler-post-array-unwrap ### 📊 Changes **1 file changed** (+7 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/noodle/noodle-noodler-generation.service.ts` (+7 -1) </details> ### 📄 Description Many LLMs (especially local models via Ollama/KoboldCPP) wrap the expected object in an array ([{"title":...}]) regardless of the prompt instructing "one JSON object". Add a guard in parseNoodlerPost to unwrap all array cases: empty -> {}, single -> first element, multiple -> first element. This resolves the 'expected object, received array' ZodError that occurs during Noodler post creation regardless of model, context, or retry attempts. > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #4597 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Noodler post creation fails with expected object, received array ZodError when LLMs (Ollama, KoboldCPP, LM Studio) return response wrapped in an array ## What changed <!-- List the key changes in this PR --> - Added array unwrap guard in parseNoodlerPost() — handles [] → {}, [{...}] → {...}, [{...}, {...}] → first element ## Validation <!-- Required: include commands run and/or manual checks performed --> - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Opened app through launcher, noodle settings, manage schedules on noodler, pressed run now on one of the scheduled profiles. It successfully generated a post. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) <!-- Add before/after screenshots or recordings for UI changes --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of generated responses containing a single result wrapped in an array. * Single-element arrays are now validated using their contained result. * Empty arrays, multi-element arrays, and direct object responses continue to be validated without changes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:10:26 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6440
No description provided.