Skip to content

Conversation

@majiayu000
Copy link

Summary

This PR fixes #1084

Changes

  • Added MarshalJSON() method to RAGStrategyConfig to preserve data during JSON serialization
  • Added MarshalYAML() method to RAGStrategyConfig to preserve data during YAML serialization
  • Added UnmarshalJSON() method to RAGStrategyConfig to properly parse flattened JSON
  • Added buildFlattenedMap() helper function shared by both marshal methods for consistent output format
  • Added comprehensive tests for JSON marshal/unmarshal and round-trip serialization

The implementation ensures that strategy-specific parameters stored in the Params map are flattened into the parent level during marshaling (matching the YAML format), preventing database field loss during round-trip serialization.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

The v2 RAGStrategyConfig type was missing marshal methods which caused
data loss during round-trip serialization. This adds:

- MarshalYAML for RAGStrategyConfig to flatten Params into parent level
- MarshalJSON for RAGStrategyConfig for JSON serialization consistency
- UnmarshalJSON for RAGStrategyConfig to capture extra fields into Params
- buildFlattenedMap helper for consistent marshal format
- MarshalYAML/MarshalJSON/UnmarshalJSON for RAGDatabaseConfig

These methods ensure that strategy-specific parameters stored in the
Params map are properly flattened during marshaling and captured during
unmarshaling, matching the behavior of the latest config version.

Fixes docker#1084

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000 majiayu000 requested a review from a team as a code owner December 30, 2025 12:00
@dgageot
Copy link
Member

dgageot commented Dec 30, 2025

@majiayu000 the linter is not happy :-)

Replace require.Equal with require.InEpsilon for floating-point
comparisons to satisfy the testifylint linter rule.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

v2 RAGStrategyConfig missing marshal methods causes database field loss during serialization

3 participants