Skip to content

2026.9.6-canary.907

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 06 Sep 09:36
· 2 commits to canary since this release
62c38b9
fix(selfhost): set correct deployment type for services (#15566)

## Description

`.docker/selfhost/compose.yml` never sets `DEPLOYMENT_TYPE`, and the
Node and Rust layers disagree about what that means.

The Node side defaults to self-hosted outside development
(`packages/backend/server/src/env.ts:97-100`). The native runtime reads
the same variable straight from the process environment and falls back
to the opposite value
(`packages/backend/native/src/runtime/config.rs:474`):

```rust
fn deployment_from_env() -> Deployment {
  if env::var("DEPLOYMENT_TYPE").as_deref() == Ok("selfhosted") {
    Deployment::SelfHosted
  } else {
    Deployment::Cloud
  }
}
```

The only process.env.DEPLOYMENT_TYPE assignments in
packages/backend/server/src are in tests and
.github/deployment/node/Dockerfile sets no default.

As a result:

* `custom_endpoint_mode` resolves to `unavailable` rather than
`disabled`/`enabled`, so `allowCustomEndpoint` in `config.json` is
silently ignored (`llm/byok/policy.rs:54`).
* The `SelfHosted && !byok_enabled` guard never fires, and
managed-provider routing is offered on an instance with no managed
access (`llm/route/policy.rs:76`, `:109`).
* Self-hosted instances get the cloud new account delay
(`rolling_quota/workspace_invite_policy.rs:194`).

The BYOK policy matrix test already pins the intended self-hosted
behavior that a default Compose deployment never reaches
(`llm/byok/policy.rs:210-212`):

```text
  (Deployment::Cloud, false, false, "unavailable", false),
  (Deployment::Cloud, true, true, "unavailable", false),
  (Deployment::SelfHosted, false, true, "disabled", false),
  (Deployment::SelfHosted, true, false, "enabled", true),
```

## Alternative considered

Changing `deployment_from_env()` to default to `SelfHosted` would repair
existing deployments without requiring users to edit their Compose
configuration, and may ultimately be the better fix. Happy to switch if
preferred.

## Checklist

- [x] I have signed the [AFFiNE Contributor License
Agreement](https://cla-assistant.io/toeverything/AFFiNE) — required
before merge; the `license/cla` check must be green ([how it
works](https://github.com/toeverything/AFFiNE/blob/canary/docs/BUILDING.md#sign-the-cla-first))
- [x] The PR targets the `canary` branch and its title follows
[Conventional Commits](https://www.conventionalcommits.org/)
- [ ] Tests are added or updated where it makes sense
- [x] `yarn lint` and `yarn typecheck` pass locally
- [ ] If the PR code includes AI-generated edits, I have carefully
reviewed it to ensure that the scope of the PR is consistent with what
is claimed in the title and description, and that there are no redundant
or invalid implementations.
- [x] I agree that maintainers may close the PR without discussion if
they consider the code quality to be too low.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Self-hosted deployments now identify their deployment type for both
the server and migration services.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->