Allow ChatGPT accounts without email (#28991)

# Summary

Codex required every ChatGPT account to have an email address. A
service-account personal access token can return valid account metadata
without one, so PAT login failed while decoding the metadata response.

This change makes email optional in the account metadata type that owns
it and preserves that absence through authentication, provider account
state, the app-server API, generated clients, and TUI bootstrap.
Existing accounts with email addresses keep the same behavior.

## Behavior-changing call sites

| Call site | Behavior after this change |
| --- | --- |
| `login/src/auth/personal_access_token.rs` | PAT metadata accepts a
missing or null email and retains `None`. |
| `agent-identity/src/lib.rs` | Agent Identity JWT claims accept an
omitted email. |
| `login/src/auth/storage.rs` and `login/src/auth/agent_identity.rs` |
Stored and managed Agent Identity records carry `Option<String>`.
Deserialization maps the legacy empty-string sentinel to `None`. |
| `login/src/auth/manager.rs` | `get_account_email` returns the stored
option, and managed identity bootstrap no longer converts `None` to an
empty string. |
| `model-provider/src/provider.rs` and `protocol/src/account.rs` | A
ChatGPT provider account requires a plan type but may carry no email. |
| `app-server-protocol/src/protocol/v2/account.rs` | `account/read`
keeps the `email` field on the wire and returns `null` when the account
has no email. Generated TypeScript and JSON schemas describe a required,
nullable field. |
| `sdk/python/src/openai_codex/generated/v2_all.py` | The generated
Python `ChatgptAccount` model accepts `None` for email. |
| `tui/src/app_server_session.rs` | Email-less ChatGPT accounts
bootstrap normally, keep external feedback routing, omit account-email
telemetry, and display the plan in account status. |

## Design decisions

- Missing email remains `None` at every layer. The code never uses an
empty string as a substitute.
- The app-server response includes `"email": null` instead of omitting
the field. Clients retain a stable response shape.
- Plan type remains required for provider account state. This change
relaxes only the email assumption.

## Testing

Tests: affected test targets compile, scoped Clippy and formatting pass,
a focused TUI snapshot covers plan-only account status, real
before/after PAT login smoke covers metadata without email, app-server
smoke covers `account/read` with `email: null`, and a regression smoke
covers an existing email-bearing PAT. Unit tests run in CI.

## Evidence

Visual smoke evidence will be attached here.
This commit is contained in:
efrazer-oai
2026-06-22 13:19:40 -07:00
committed by GitHub
parent 1659c4a629
commit 5a67d898a5
29 changed files with 485 additions and 61 deletions
@@ -10,6 +10,7 @@ from pathlib import Path
import pytest
import tomllib
from pydantic import ValidationError
ROOT = Path(__file__).resolve().parents[1]
@@ -306,6 +307,32 @@ def test_schema_normalization_only_flattens_string_literal_oneofs(
]
def test_schema_normalization_makes_chatgpt_account_email_nullable() -> None:
script = _load_update_script_module()
schema = {
"definitions": {
"Account": {
"oneOf": [
{
"properties": {
"email": {"type": "string"},
"type": {"enum": ["chatgpt"], "type": "string"},
},
"required": ["email", "type"],
"type": "object",
}
]
}
}
}
script._make_chatgpt_account_email_nullable(schema)
chatgpt_account = schema["definitions"]["Account"]["oneOf"][0]
assert chatgpt_account["properties"]["email"]["type"] == ["string", "null"]
assert "email" in chatgpt_account["required"]
def test_python_codegen_schema_annotation_adds_stable_variant_titles(
tmp_path: Path,
) -> None:
@@ -350,6 +377,17 @@ def test_generate_v2_all_uses_titles_for_generated_names() -> None:
assert "ruff-format" in source
def test_generated_chatgpt_account_email_is_required_nullable() -> None:
from openai_codex.generated.v2_all import ChatgptAccount
account = ChatgptAccount.model_validate({"email": None, "planType": "pro", "type": "chatgpt"})
assert account.email is None
assert ChatgptAccount.model_fields["email"].is_required()
with pytest.raises(ValidationError):
ChatgptAccount.model_validate({"planType": "pro", "type": "chatgpt"})
def test_runtime_package_template_has_no_checked_in_binaries() -> None:
runtime_root = ROOT.parent / "python-runtime" / "src" / "codex_cli_bin"
assert sorted(