Skip to content

DM-54689: Extract _require_github_app_config() helper in Factory to dedupe three-way None check #267

@jonathansick

Description

@jonathansick

Metadata

Field Value
Parent PRD #232
Jira Key DM-54689
Jira URL https://rubinobs.atlassian.net/browse/DM-54689
Task Order 22
Type AFK
Blocked by None
Parallel with #266, #268, #269
Branch tickets/DM-54689-github-webhook

Origin

Review of PR #264

What to build

src/docverse/factory.py repeats the same three-way is None check on _github_app_id, _github_app_private_key, and _github_webhook_secret in two methods:

  • create_github_app_client (lines ~300-306).
  • get_github_webhook_secret (lines ~420-441).

Both raise GitHubAppNotConfiguredError with the same message. Extract a private helper so the two sites cannot drift.

Approach sketch

Add _require_github_app_config(self) -> tuple[int, SecretStr, SecretStr] (or a small named tuple / dataclass) that performs the all-or-nothing check and returns the three values typed as non-None. Both call sites delegate. Helper raises GitHubAppNotConfiguredError with the existing message.

Acceptance criteria

  • One private helper performs the three-way None check and returns the resolved values.
  • create_github_app_client and get_github_webhook_secret call the helper.
  • No duplicated if ... is None or ... is None or ... is None blocks remain in factory.py.
  • Existing factory and webhook tests pass unchanged.
  • uv run --only-group=nox nox -s typing clean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    prd-taskImplementation task from a PRD

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions