Skip to content

auth create silently defaults to the Anytype Network when --network-config is omitted (opaque failures for self-hosted users) #51

Description

@benwilks

Summary

anytype auth create (and space join when no cached config exists) silently default to the public Anytype Network when --network-config is not provided. For users running a self-hosted any-sync deployment, this means the account is stamped with the wrong network ID and never becomes reachable from their own backend — but the CLI emits no warning at create-time or join-time. The only visible failure is later, when space join returns an opaque DeadlineExceeded or ipld: could not find <cid> error.

SELF-HOSTED.md does prescribe the --network-config flag, so this isn't a docs gap. The issue is the silent failure mode when a user — especially a first-time self-hoster — omits it.

Symptom

$ anytype auth create my-bot
✓ Bot account created successfully!
...
$ anytype space join "https://<self-hosted-host>/<cid>#<key>"
✗ Failed to view invite: failed to view space invite: rpc error: code = DeadlineExceeded desc = context deadline exceeded

Variants seen in practice include:

  • rpc error: ... DeadlineExceeded at ViewSpaceInvite (peer dial timeout against unreachable Anytype Network nodes from the user's self-hosted setup).
  • ipld: could not find <cid> when the invite blob lookup goes out on the wrong network.
  • Heart-side log, only visible if the user knows to look: ERROR can't init service service:config error: network id mismatch.

The CLI itself gives no hint that the account was stamped with the production network ID.

Root cause

Both auth create and space join quietly fall back to the public Anytype Network ID constant (N83gJpVd9MuNRZAuJLZ7LiMntTThhPc6DtzWWVjb1M3PouVUAnytypeNetworkAddress in core/config/constants.go):

1. auth create (core/auth.go, CreateWallet + determineNetworkMode):

func determineNetworkMode(networkConfigPath string) pb.RpcAccountNetworkMode {
    if networkConfigPath != "" {
        return pb.RpcAccount_CustomConfig
    }
    return pb.RpcAccount_DefaultConfig   // ← silently selects the Anytype Network
}

CreateWallet passes NetworkMode: DefaultConfig to heart's AccountCreate gRPC, which stamps account state with the production network ID. No warning is emitted in the --network-config=="" branch. The fallback is also written through to AccountSelect, so subsequent operations inherit the stamp.

2. space join (cmd/space/join/join.go, resolveNetworkId):

func resolveNetworkId() string {
    if cachedId, err := config.GetNetworkIdFromConfig(); err == nil && cachedId != "" {
        return cachedId
    }
    if yamlPath, _ := config.GetNetworkConfigPathFromConfig(); yamlPath != "" {
        if id, err := config.ReadNetworkIdFromYAML(yamlPath); err == nil && id != "" {
            _ = config.SetNetworkIdToConfig(id)
            return id
        }
    }
    return config.AnytypeNetworkAddress   // ← same silent fallback
}

Once the account has been created without --network-config, neither the cached networkId nor networkConfigPath is populated (CreateWallet only writes networkConfigPath to config when it's non-empty), so space join ends up at the production constant too. Heart then tries to dial Anytype Network peers to fetch the (self-hosted) invite blob, and the user sees the timeout.

Reproduction

On a host where ~/.anytype/config.json doesn't exist yet:

anytype auth create my-bot
# no warning; account silently created on the public Anytype Network
anytype space join "https://<self-hosted-host>/<cid>#<key>"
# → "Failed to view invite: ... DeadlineExceeded"
#   or "ipld: could not find <cid>"

Expected: a warning (or interactive confirm) at auth create along the lines of "no --network-config provided; account will be created on the public Anytype Network — for self-hosted, pass --network-config /path/to/network.yml."

Actual: silent stamp on the wrong network; opaque failure 1–2 commands later with no clear hint to look at network configuration.

Suggested fix

The strongest single change would be to warn at auth create when --network-config is omitted and no cached config exists, since that's where account state is stamped permanently:

⚠ No --network-config provided; account will be created on the public Anytype Network.
  For a self-hosted any-sync deployment, pass --network-config <path/to/network.yml>.

Either as a non-interactive stderr warning (proceed by default, opt out with e.g. --accept-default-network for CI) or as an interactive [y/N] confirm — maintainers' call on which fits the CLI's UX better.

Secondary, less critical: emit the same warning in resolveNetworkId() when the fallback to AnytypeNetworkAddress fires, so users who installed before any fix also get a hint at space join time.

Workaround

Always pass --network-config /path/to/network.yml on auth create (as SELF-HOSTED.md prescribes). If an account has already been stamped on the wrong network, the recovery path is anytype auth logout followed by anytype auth create --network-config ... — the account state itself can't be re-pointed.

Possibly the same bug

#36 reports DeadlineExceeded at space join after auth create my-bot (no --network-config). The symptom matches the root cause described above. That report also raises macOS keychain and code-signing concerns that are independent of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions