sipeed/picoclaw · error

decode config %s: %w

Error message

decode config %s: %w

What it means

The get_config result did not unmarshal into *string: the server returned JSON other than string or null for the requested key. This is a schema/shape mismatch between the installed deltachat-rpc-server and the shapes this client assumes.

Source

Thrown at pkg/channels/deltachat/deltachat.go:1110

		return
	}
	stopCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
	_, _ = c.rpc.call(stopCtx, "stop_ongoing_process", accountID)
	cancel()

	removeCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
	_, _ = c.rpc.call(removeCtx, "remove_account", accountID)
	cancel()
}

func (c *DeltaChatChannel) getAccountConfigString(ctx context.Context, accountID int64, key string) (string, error) {
	raw, err := c.rpc.call(ctx, "get_config", accountID, key)
	if err != nil {
		return "", fmt.Errorf("get config %s: %w", key, err)
	}
	var value *string
	if err := json.Unmarshal(raw, &value); err != nil {
		return "", fmt.Errorf("decode config %s: %w", key, err)
	}
	if value == nil {
		return "", nil
	}
	return *value, nil
}

func (c *DeltaChatChannel) passwordRequiredError(reason string) error {
	return fmt.Errorf("deltachat: account %s is not configured in data_dir %s (%s)",
		c.config.Email, c.dataDir, reason)
}

func (c *DeltaChatChannel) applyProfileConfig(ctx context.Context, accountID int64) error {
	cfgMap := map[string]*string{}
	if name := strings.TrimSpace(c.config.DisplayName); name != "" {
		cfgMap["displayname"] = accountConfigString(name)
	}
	if avatar := strings.TrimSpace(c.config.AvatarImage); avatar != "" {

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Log the raw payload (json.RawMessage) to see the actual shape returned
  2. Pin the deltachat-rpc-server version to one matching this PicoClaw build
  3. Report the shape change upstream if a stock server produces it
Defensive patterns

Strategy: try-catch

Try / catch

raw, callErr := c.rpc.call(ctx, "get_config", id, key)
if callErr != nil {
    return "", fmt.Errorf("get config %s: %w", key, callErr)
}
var v any
if err := json.Unmarshal(raw, &v); err != nil {
    log.Warn("unexpected config shape", "key", key, "raw", string(raw))
    return "", fmt.Errorf("decode config %s: %w", key, err)
}

Prevention

When it happens

Trigger: json.Unmarshal(raw, &value) fails because raw is a number, object, or array (e.g. a core returning numeric values for keys like ports).

Common situations: deltachat-rpc-server version skew after an upgrade/downgrade; a custom fork of the RPC server changing result encoding.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/af46fd64b7b465cb. Report an issue: GitHub.