Skip to content

fix(channels): prevent legacy flat config from blocking new account creation#837

Open
octo-patch wants to merge 2 commits into
ValueCell-ai:mainfrom
octo-patch:fix/issue-831-channel-add-account-skip
Open

fix(channels): prevent legacy flat config from blocking new account creation#837
octo-patch wants to merge 2 commits into
ValueCell-ai:mainfrom
octo-patch:fix/issue-831-channel-add-account-skip

Conversation

@octo-patch

Copy link
Copy Markdown
Contributor

Fixes #831

Problem

When a channel (e.g. DingTalk) is stored in the legacy flat format — a config section without an explicit accounts object — getChannelConfig() falls back to returning the entire top-level channel section for any requested accountId.

This interacts badly with the isSameConfigValues() guard in POST /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 isSameConfigValues early-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 specific accountId is 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, undefined is returned — the correct "not found" signal — allowing the save to proceed and the new account to be created.

// Before
if (!accounts || Object.keys(accounts).length === 0) {
    return channelSection;
}

// After
if ((!accounts || Object.keys(accounts).length === 0) && (!accountId || resolvedAccountId === DEFAULT_ACCOUNT_ID)) {
    return channelSection;
}

Testing

  • Configure a channel (e.g. DingTalk) that was saved in legacy flat format
  • Click "Add Account" and enter credentials identical to the existing account
  • Verify the save proceeds (new account appears in the list) rather than being silently swallowed
  • Verify that fetching config for the default/unspecified account still falls back correctly to the flat legacy format

octo-patch added 2 commits April 11, 2026 09:25
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +45 to +46
if (msg.includes('already running under systemd')) {
return { level: 'debug', normalized: msg };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

[Bug]: 频道里,添加账号实际上点提交后是编辑原有的,0.38版本有这个问题

1 participant