Skip to content

SEP-1650: Pin the always-emitted ENCRYPT invariant for MySQL backup configs - #1305

Open
olucasandrade wants to merge 2 commits into
mainfrom
SEP-1650
Open

SEP-1650: Pin the always-emitted ENCRYPT invariant for MySQL backup configs#1305
olucasandrade wants to merge 2 commits into
mainfrom
SEP-1650

Conversation

@olucasandrade

@olucasandrade olucasandrade commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a contract test that drives build_backup_spec directly and asserts the serialized YAML config always carries an explicit ENCRYPT key — for all three backup types (mydumper, xtrabackup, binlog), across an encrypt=True form, an encrypt=False form, and a form built with no encryption fields supplied. The test fails if exclude_unset/exclude_defaults is ever introduced into the builder, or if any future change lets the key be omitted from the emitted config.
  • Records the deliberate fail-safe intent at the three payload settings.get("ENCRYPT", True) sites so a future reader does not "fix" them into alignment with the form/config model default (False, an unchecked box). An absent ENCRYPT on a standalone run against hand-authored config must mean encrypt, never silently produce an unencrypted backup on a customer host.
  • No payload behavior change; on-wire config key names are unchanged and the payload snapshot golden (tests/app/sep/snapshots/payload/mysql_backups__spec_path.json) is untouched.

Closes SEP-1650. Written against the post-SEP-1623 field shape (SEP-1623 / #1184 is merged to main).

Tested

N/A — test-and-annotation change with no user-facing or payload behavior change. Verified via automated tests:

  • make test PYTEST_PATHS=tests/app/sep/apps/mysql_backups/test_payload_snapshot.py — 10 passed (the new test_build_backup_spec_always_emits_encrypt_key matrix + the unchanged test_spec_path_payload_matrix_matches_golden).
  • Negative check: temporarily adding exclude_defaults=True to the builder's jsonable_encoder makes the encrypt=False/omitted cases fail, confirming the guard bites; reverted.

Checklist

  • New/modified functions have type hints and rST docstrings
  • New tests added for new features or bug fixes
  • All tests pass locally (make test) (mysql_backups suite: 427 passed; 1 pre-existing environmental failure in restore/test_xtrabackup_aes256_restore.py from the external xbcrypt AES256 binary, unrelated to this change)
  • Pre-commit hooks pass (make run-pre-commit)
  • Database migrations generated if models changed (N/A — no model change)
  • User-facing changes documented (N/A — no user-facing change)
  • Configuration changes documented with examples (N/A)
  • Changelog fragment added (N/A — internal test + code-comment change, no user-facing behavior)

…onfigs

Add a contract test that drives build_backup_spec directly and asserts the
serialized YAML always carries an explicit ENCRYPT key for all three backup
types (mydumper, xtrabackup, binlog), across an encrypt=True form, an
encrypt=False form, and a form built without any encryption fields. The test
fails if exclude_unset/exclude_defaults is ever introduced into the builder or
any change lets the key be omitted from the emitted config.

Record the deliberate fail-safe intent at the three payload settings.get(
"ENCRYPT", True) sites so a future reader does not align them to the form/config
model default (False). No payload behavior change and the payload snapshot
golden is unchanged.
@github-actions github-actions Bot added the python label Aug 7, 2026
@olucasandrade
olucasandrade marked this pull request as ready for review August 7, 2026 19:23
Copilot AI review requested due to automatic review settings August 7, 2026 19:23
@olucasandrade
olucasandrade requested a review from a team as a code owner August 7, 2026 19:23
@olucasandrade olucasandrade added the qa passed Tests for this PR are completed and successful. label Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a contract-style regression test to ensure MySQL backup specs emitted by build_backup_spec always serialize an explicit ENCRYPT key, and documents the intentional fail-safe default (settings.get("ENCRYPT", True)) in each payload so future changes don’t accidentally weaken the safety posture.

Changes:

  • Add a parametrized contract test asserting ENCRYPT is always present in the emitted YAML config for all backup types and encryption input shapes.
  • Add inline comments at the three payload settings.get("ENCRYPT", True) sites to record the deliberate “absent means encrypt” intent.
  • No functional payload behavior changes; existing snapshot golden remains unchanged.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/app/sep/apps/mysql_backups/test_payload_snapshot.py Adds a new contract test + helper to assert ENCRYPT is always emitted in build_backup_spec YAML output.
app/sep/apps/mysql_backups/xtrabackup_payload Documents the intentional fail-safe default for missing ENCRYPT in config.
app/sep/apps/mysql_backups/mydumper_payload Documents the intentional fail-safe default for missing ENCRYPT in config.
app/sep/apps/mysql_backups/binlog_payload Documents the intentional fail-safe default for missing ENCRYPT in config.
Suppressed comments (1)

tests/app/sep/apps/mysql_backups/test_payload_snapshot.py:224

  • This test introduces a bare dict type annotation for encryption. Please parameterize it (e.g. dict[str, object]) to avoid erasing the value type contract.
def test_build_backup_spec_always_emits_encrypt_key(backup_type: str, encryption: dict):

)


def _all_servers_config(backup_type: str, encryption: dict) -> dict:
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  app/sep
  inventory.py
  app/sep/apps/mysql_backups
  mydumper_payload 1383-1393
  xtrabackup_payload 1468-1478
  app/sep/apps/mysql_backups/restore
  deps.py
  app/sep/sync/syncers
  pmm.py
Project Total  

This report was generated by python-coverage-comment-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python qa passed Tests for this PR are completed and successful.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants