Skip to content

fix(platform-config): send full config payload on update (FT-1941)#38

Open
joalves wants to merge 6 commits into
mainfrom
feat/FT-1941/platform-config-update-fix
Open

fix(platform-config): send full config payload on update (FT-1941)#38
joalves wants to merge 6 commits into
mainfrom
feat/FT-1941/platform-config-update-fix

Conversation

@joalves
Copy link
Copy Markdown
Collaborator

@joalves joalves commented May 21, 2026

Summary

Fixes FT-1941. abs platform-config update <id> --value <json> was returning HTTP 500 (Cannot use 'in' operator to search for 'archived' in 30) because the CLI was sending {"data": <raw-value>} instead of the required {"data": {"name": "...", "value": "...", ...}}.

  • Core (src/core/platformconfig/platformconfig.ts): now GETs the current config, merges the new value over it, drops id (it's in the URL path), and PUTs the full object. UpdatePlatformConfigParams.value is now unknown so the CLI can pass any JSON value (string, number, object, array).
  • CLI (src/commands/platformconfig/index.ts): dropped the misleading as Record<string, unknown> cast on validateJSON(--value). Config values in the wild are often non-object JSON ("30", 42, booleans).
  • API client (src/api-client/api-client.ts): unchanged. Investigation showed { data: { data } } is JS shorthand producing the correct { data: <param> } wire body; the original bug was upstream. Added a regression test that pins the wire shape so a future refactor can't reintroduce the symptom.

Test plan

  • npx vitest run src/core/platformconfig src/commands/platformconfig src/api-client — 10/10 platform-config tests + the api-client regression guard pass
  • npx vitest run (full suite) — 2382/2382 pass, 4 skipped
  • npx tsc --noEmit — clean
  • Live verified against dev-1: GET→PUT round-trip on configs 22 (experiment_form_max_secondary_metrics) and 23 (experiment_form_max_guardrail_metrics); both returned 200, updated_at advanced, all fields preserved
  • --show-request output confirms the wire body is {"data": {"name": "...", "value": "30", "default_value": ..., ...}}

Summary by CodeRabbit

Release Notes

Bug Fixes

  • Improved platform config update functionality to properly merge new values with existing configuration whilst preserving other config fields.
  • Enhanced error handling with clearer messaging when attempting to update a platform config that cannot be found.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aebde5f8-4bcf-477f-a3ca-fc2744e171f8

📥 Commits

Reviewing files that changed from the base of the PR and between 690880f and 038e410.

📒 Files selected for processing (5)
  • src/api-client/api-client.test.ts
  • src/commands/platformconfig/index.ts
  • src/commands/platformconfig/platformconfig.test.ts
  • src/core/platformconfig/platformconfig.test.ts
  • src/core/platformconfig/platformconfig.ts

Walkthrough

This pull request refactors the platform config update flow to adopt a read-before-write pattern. Previously, updatePlatformConfig directly sent the provided value to the API. Now it fetches the existing platform config, validates it exists and is an object, strips the id field, merges the provided value into the remaining fields, and sends the merged payload to the API. The value type in UpdatePlatformConfigParams has been broadened from Record<string, unknown> to unknown to support any JSON type. Tests across the core service, command, and API layers have been updated to verify the fetch-merge-update logic, diverse value types, and the required wire format.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A config now reads before it writes,
Fetches the old, then merges new delights,
No id escapes, the payload's condensed,
Values of any JSON type enhanced—
Tested at three layers, all is right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: sending the full config payload on platform-config update, addressing the core issue (FT-1941) identified in the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/FT-1941/platform-config-update-fix

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant