Skip to content

Escape braces in JSON log output to prevent loguru formatting#105

Merged
aidankhogg merged 7 commits into
dev/alphafrom
claude/netengine-migration-import-hw79l7
Jun 29, 2026
Merged

Escape braces in JSON log output to prevent loguru formatting#105
aidankhogg merged 7 commits into
dev/alphafrom
claude/netengine-migration-import-hw79l7

Conversation

@aidankhogg

Copy link
Copy Markdown
Contributor

Summary

Fixed an issue where JSON log entries were being incorrectly processed by loguru's format_map function, which was interpreting JSON object keys as format string placeholders.

Changes

  • Modified format_record_json() in netengine/logging/core.py to escape curly braces in the JSON output by replacing { with {{ and } with }}
  • This prevents loguru from attempting to substitute JSON keys as format string variables

Implementation Details

The fix ensures that JSON log entries are properly escaped before being returned. By doubling the curly braces, the output is compatible with loguru's format string processing while preserving the original JSON structure for downstream consumers.

https://claude.ai/code/session_01RResBJyUf3NWWSY7VBCR7z

claude added 7 commits June 29, 2026 02:33
…t_map KeyError

Loguru calls str.format_map() on the string returned by a format callable,
which caused KeyError when the JSON output contained {-delimited keys.
Escaping { and } before returning lets format_map pass through safely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RResBJyUf3NWWSY7VBCR7z
…and tests

- run_migrations.py: rewrite to remove three overlapping corrupt fragments;
  now a clean wrapper over netengine.db.migrations.run_migrations
- type: ignore[import] → [import-untyped] in migration_service, db/migrations,
  core/migrations; remove now-unused ignore in docker_factory
- diagnostic/preflight: add generic type args to _compose_config return
- spec/loader: suppress attr-defined for private PydanticUndefined import;
  wrap != comparison in bool() to satisfy no-any-return
- pki_cert_rotation_worker: use IssuedCertificateMetadata in callback type
  to match what state.issued_certificates actually yields
- init_wizard: disable reverse_dns in business/datacenter AND profiles (unsupported in alpha)
- test_api_auth: rewrite corrupt test file; add missing `patch` import and
  fix _Session mock to properly capture ssl kwarg and return introspection data;
  supply platform_client_secret in _phase4_state helper
- test_dns_add_zone_record_callers: replace stale DockerHandler patch with
  docker_client assignment (phase_pki no longer imports DockerHandler directly)
- test_orchestrator_m3 / test_e2e_bootstrap: set pki_output so
  _discard_completion_flags_without_outputs does not strip phase_completed["3"]
- black formatting on all affected files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RResBJyUf3NWWSY7VBCR7z
- Remove stale # type: ignore[import-untyped] from runtime asyncpg imports
  in core/migrations.py, db/migrations.py, utils/migration_service.py
  (asyncpg now has stubs so the ignores are unused)
- Fix preflight.py _compose_config return type dict[str, object] -> dict[str, Any]
  so callers can use .keys()/.items() without attr-defined errors
- Revert CertTypeRotationConfig.rotation_callback to Dict[str, Any] to match
  the existing _callbacks dict type and avoid callback contravariance errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RResBJyUf3NWWSY7VBCR7z
…flight check

- Restore type: ignore[import-untyped] on first asyncpg import in
  core/migrations.py and db/migrations.py (mypy needs it on the first
  in-function import; subsequent imports in the same file are cached)
- Cast cert_metadata to Dict[str, Any] when invoking rotation_callback
  in pki_cert_rotation_worker to satisfy mypy arg-type check
- Remove post-docstring blank lines in migration_service.py to satisfy
  black 25.x formatting rules
- Add _check_docker_subnet_conflicts to preflight doctor checks: warns
  when any existing Docker network subnet overlaps with subnets defined
  in docker-compose.yml, preventing bootstrap failures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RResBJyUf3NWWSY7VBCR7z
…_service.py

Black 24.x (project-pinned version) reformats these files differently from
26.x. Applied formatting via black==24.10.0 to match what CI expects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RResBJyUf3NWWSY7VBCR7z
…ll files

The 4be7b03 partial-revert left admin_password undefined after 553c25e had
renamed it to client_secret; fix auth=BasicAuth to use (client_id, client_secret).

Also apply isort 5.13.2 formatting to 16 files that CI flags as incorrectly
sorted — these are pre-existing isort violations unrelated to this branch's
feature work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RResBJyUf3NWWSY7VBCR7z
…light.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RResBJyUf3NWWSY7VBCR7z
@aidankhogg aidankhogg self-assigned this Jun 29, 2026
@aidankhogg aidankhogg added the bug Something isn't working label Jun 29, 2026
@aidankhogg aidankhogg merged commit d597007 into dev/alpha Jun 29, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants