fix: channel editors silently dropping unknown fields on save#88
Merged
Iamlovingit merged 8 commits intoYuan-lab-LLM:mainfrom Apr 29, 2026
Merged
Conversation
e2ab157 to
52090a6
Compare
1aee7ac to
965f99f
Compare
Collaborator
|
@naiqus Hi, this PR has conflicts. Could you please help resolve them? Thanks! |
Every channel form editor (telegram, dingtalk-connector, slack, feishu)
silently drops fields on Save. The user flow that loses data:
1. Open a channel resource in the JSON tab, add any field not owned
by the form (e.g. webhook, custom capabilities, additional feishu
accounts).
2. Switch to the Form tab and change anything (e.g. rotate a secret).
3. Click Save.
4. The field from step 1 is gone from the saved config — and stays
gone after a reload.
The data loss occurs in two places; both must be fixed:
Frontend (OpenClawConfigCenterPage.tsx):
Each update*ChannelContentText rebuilt the output from a hard-coded
allowlist instead of merging form fields into the parsed config. Any
field not in the allowlist was dropped on Save. For feishu this
collapsed a multi-account config to a single `main` account.
Backend (openclaw_config_service.go):
normalizeOpenClawResourceContent calls normalize*ChannelConfigForEnv
on every create/update to validate and rebuild the stored config.
Those helpers use the same allowlist pattern, so even if the
frontend sends a complete config, the backend strips tenant-authored
keys before persisting.
Fix:
- Frontend: introduce a single mergeChannelConfig(existing, allowlisted)
helper and route every editor's output through it. Each handler
builds an allowlisted object containing only its known keys; the
helper overlays it onto the parsed existing config so unknown keys
survive. The merge point is now structural rather than a per-handler
convention, so a new editor (e.g. an MS Teams handler added in a
downstream patch) can't regress by forgetting the spread. Feishu's
accounts deep-merge is preserved by building the merged accounts
inside the allowlisted object before handing off to the helper.
- Backend: introduce mergeOpenClawChannelConfigForStorage, which
overlays the allowlist-normalized output onto the original parsed
payload at storage time. Normalized keys still win; unknown keys
pass through. For feishu the accounts map is merged member-wise.
Env-rendering semantics are unchanged. appendCompiledOpenClawEnvPayload
continues to call the *ForEnv helpers at render time against the
stored content, so the runtime env payload sees the same allowlist as
before.
Tests:
- Two existing ResourcePayloadFromModelNormalizesStored*JSON tests
asserted the pre-fix behavior (dropping `legacyField`) and are
updated to assert it survives.
- New TestNormalizeOpenClawResourceContentPreservesUnknownChannelFields
(table-driven, three editors) guards the preservation invariant.
- New TestNormalizeOpenClawResourceContentPreservesFeishuSiblingAccounts
guards the feishu deep-merge.
Manual verification against a live instance: add `webhook` via the
JSON tab, switch to Form tab, rotate a secret, Save, reload — the
webhook field is retained.
965f99f to
87fe5a6
Compare
Contributor
Author
|
Sure. It has been resolved now. |
…ead of ensuring default
Kubernetes defaults imagePullPolicy to Always when the image tag is :latest. This causes pod creation failures in air-gapped and enterprise environments where nodes cannot reach external registries. Changes: - Add ImagePullPolicy field to PodConfig struct - Default to IfNotPresent in CreatePod when not explicitly set - Support IMAGE_PULL_POLICY env var for operator override - Apply policy to both CreateInstance and StartInstance paths Closes Yuan-lab-LLM#94
fix(instances): delete legacy network policy before create/start instead of ensuring default
…y-configurable fix: default imagePullPolicy to IfNotPresent for air-gapped environments
Every channel form editor (telegram, dingtalk-connector, slack, feishu)
silently drops fields on Save. The user flow that loses data:
1. Open a channel resource in the JSON tab, add any field not owned
by the form (e.g. webhook, custom capabilities, additional feishu
accounts).
2. Switch to the Form tab and change anything (e.g. rotate a secret).
3. Click Save.
4. The field from step 1 is gone from the saved config — and stays
gone after a reload.
The data loss occurs in two places; both must be fixed:
Frontend (OpenClawConfigCenterPage.tsx):
Each update*ChannelContentText rebuilt the output from a hard-coded
allowlist instead of merging form fields into the parsed config. Any
field not in the allowlist was dropped on Save. For feishu this
collapsed a multi-account config to a single `main` account.
Backend (openclaw_config_service.go):
normalizeOpenClawResourceContent calls normalize*ChannelConfigForEnv
on every create/update to validate and rebuild the stored config.
Those helpers use the same allowlist pattern, so even if the
frontend sends a complete config, the backend strips tenant-authored
keys before persisting.
Fix:
- Frontend: introduce a single mergeChannelConfig(existing, allowlisted)
helper and route every editor's output through it. Each handler
builds an allowlisted object containing only its known keys; the
helper overlays it onto the parsed existing config so unknown keys
survive. The merge point is now structural rather than a per-handler
convention, so a new editor (e.g. an MS Teams handler added in a
downstream patch) can't regress by forgetting the spread. Feishu's
accounts deep-merge is preserved by building the merged accounts
inside the allowlisted object before handing off to the helper.
- Backend: introduce mergeOpenClawChannelConfigForStorage, which
overlays the allowlist-normalized output onto the original parsed
payload at storage time. Normalized keys still win; unknown keys
pass through. For feishu the accounts map is merged member-wise.
Env-rendering semantics are unchanged. appendCompiledOpenClawEnvPayload
continues to call the *ForEnv helpers at render time against the
stored content, so the runtime env payload sees the same allowlist as
before.
Tests:
- Two existing ResourcePayloadFromModelNormalizesStored*JSON tests
asserted the pre-fix behavior (dropping `legacyField`) and are
updated to assert it survives.
- New TestNormalizeOpenClawResourceContentPreservesUnknownChannelFields
(table-driven, three editors) guards the preservation invariant.
- New TestNormalizeOpenClawResourceContentPreservesFeishuSiblingAccounts
guards the feishu deep-merge.
Manual verification against a live instance: add `webhook` via the
JSON tab, switch to Form tab, rotate a secret, Save, reload — the
webhook field is retained.
…om:naiqus/ClawManager into fix/openclaw-channel-editor-field-dropping
TestNormalizeOpenClawResourceContentPreservesUnknownChannelFields and TestNormalizeOpenClawResourceContentPreservesFeishuSiblingAccounts were declared twice causing build failure.
Collaborator
|
/lgtm |
Collaborator
|
@naiqus Thanks your contributions! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
All four channel form editors in
OpenClawConfigCenterPage.tsx(telegram, dingtalk-connector, slack, feishu) silently drop fields on Save.User flow that loses data:
webhook, custom capabilities, additional feishu accounts).Root cause — two lossy layers
Both the frontend editor and the backend storage normalizer rebuild each config from a hard-coded field allowlist instead of merging the patch onto the existing parsed config. Fixing only one of them is not enough to survive a reload.
Frontend:
update*ChannelContentTextinOpenClawConfigCenterPage.tsxEvery key not in that literal is silently deleted. Feishu is the worst case — it collapses
accountsto just{ main: {...} }.Backend:
normalizeOpenClawResourceContentinopenclaw_config_service.goCalled on every create/update; delegates to
normalize{Telegram,Slack,DingTalk,Feishu}ChannelConfigForEnv. Those helpers serve double duty — they are correct for rendering the runtime env payload (appendCompiledOpenClawEnvPayloadre-runs them at render time), but when applied verbatim as the storage normalizer they strip tenant-authored keys before persisting.Concrete loss matrix (pre-fix)
enabled,botToken,dmPolicy,allowFromwebhook, custom capabilities, any custom keysenabled,clientId,clientSecret,allowFromdmPolicy,webhook, custom keysenabled,botToken,appToken,groupPolicy,channels,capabilitiesallowFrom,dmPolicy, custom keysenabled,accounts.mainonlymain; every sibling field onaccounts.main(e.g.verificationToken); every other top-level fieldFix
Frontend — spread
existingConfigfirst, then override only form-owned keys so later literal keys win. Fallbacks (|| "open",|| ["*"]) still evaluate againstexistingConfig. For feishu also deep-merge theaccountsmap andaccounts.mainso sibling accounts and sibling fields both survive.Backend — introduce
mergeOpenClawChannelConfigForStorage, which overlays the allowlist-normalized output onto the original parsed payload at storage time. Normalized keys still win; unknown keys pass through. For feishu theaccountsmap is merged member-wise.Env-rendering semantics are unchanged:
appendCompiledOpenClawEnvPayloadcontinues to call the*ForEnvhelpers at render time against the stored content, so the runtime env payload sees the same allowlist as before. Only storage is now a superset.Diff
Verification
Backend tests
Two existing tests (
TestResourcePayloadFromModelNormalizesStored{Channel,DingTalkChannel}JSON) asserted the pre-fix behavior (droppinglegacyField); updated to assert it survives.New regression guards:
TestNormalizeOpenClawResourceContentPreservesUnknownChannelFields— table-driven across telegram / dingtalk-connector / slack, assertswebhook,dmPolicy,allowFrom, customcapabilitiesall survive write-time normalization.TestNormalizeOpenClawResourceContentPreservesFeishuSiblingAccounts— asserts deep-merge of feishu accounts:defaultandacmesurvive untouched;main.verificationTokensurvives;main.appId/main.appSecretare still normalized.The existing render-path test (
TestRenderCompiledOpenClawPayloadRendersChannelsAsKeyedConfigMap) continues to pass unchanged, proving the env-render allowlist is not affected.