fix(channels): prevent legacy flat config from blocking new account creation#837
fix(channels): prevent legacy flat config from blocking new account creation#837octo-patch wants to merge 2 commits into
Conversation
When the openclaw gateway binary is already managed by systemd it emits "already running under systemd; waiting 5000ms before retrying startup" to stderr and loops internally. ClawX previously classified the resulting process exit as a transient error and retried the startup sequence (up to 3 attempts in the orchestrator, then up to 10 via the reconnect manager), producing a long visible retry storm with no recovery path. Detect this signal in startup-recovery and return 'fail' immediately so the manager surfaces a clear error state on the first attempt. Also downgrade the log level for the message to 'debug' in startup-stderr so the short window before the process exits does not flood the log. Fixes ValueCell-ai#695
…reation When a channel is stored in the legacy flat format (no accounts object), getChannelConfig() falls back to returning the flat top-level section for any accountId. This caused isSameConfigValues() in the POST /api/channels/config handler to report a false 'no change' result when the user's new-account credentials matched the existing flat config, silently skipping the save. Guard the backward-compat fallback so it only activates when no specific accountId is supplied or when the default accountId is requested. Callers that pass a newly-generated accountId (e.g. 'dingtalk-abc12345') will now receive undefined, allowing the save to proceed and the new account to be created correctly. Fixes ValueCell-ai#831
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b9708d675
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (msg.includes('already running under systemd')) { | ||
| return { level: 'debug', normalized: msg }; |
There was a problem hiding this comment.
Keep systemd conflict line visible in production logs
Downgrading already running under systemd to debug hides the only specific root-cause signal in packaged builds, because the logger defaults to INFO there and debug messages are suppressed. In the failure path, startup still surfaces a generic error (Gateway process exited before becoming ready), so this change makes real systemd conflicts much harder to diagnose from user logs/support bundles even though the app now fails fast.
Useful? React with 👍 / 👎.
Fixes #831
Problem
When a channel (e.g. DingTalk) is stored in the legacy flat format — a config section without an explicit
accountsobject —getChannelConfig()falls back to returning the entire top-level channel section for any requestedaccountId.This interacts badly with the
isSameConfigValues()guard inPOST /api/channels/config: when a user clicks Add Account and enters the same credentials as the existing channel,getChannelFormValues()returns the existing flat config as if it belonged to the brand-new UUID-based accountId (e.g.dingtalk-abc12345).isSameConfigValues()then reports "no change" and returns{ success: true, noChange: true }— silently skipping the save.From the user's perspective, clicking "Add Account → Submit" appears to succeed (no error) but no new account appears in the list, giving the impression the existing account was edited in-place.
This regression was introduced when the
isSameConfigValuesearly-return was added in #496 (after the accounts-based storage refactor in #420) and affects any user whose channel config predates the accounts migration.Solution
Guard the backward-compat fallback in
getChannelConfig()so it only applies when no specificaccountIdis requested, or when the default ('default') accountId is requested. When the caller supplies a newly-generated account ID that does not exist in the config,undefinedis returned — the correct "not found" signal — allowing the save to proceed and the new account to be created.Testing