feat(config): add v1-to-v2 profiles.json migration helper (#105) #123
Reference in New Issue
Block a user
Delete Branch "feat/issue-105-profiles-migration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #105
Add a migration helper script migrate_profiles.py to convert version 1 profiles.json to version 2 environments shape, preserving keychain references and creating aliases for backwards compatibility. Includes full unit test coverage.
Requesting changes for the pinned PR #123 head
cd633e2c2b.Findings:
git diff --checkfails. There is trailing whitespace in both added files (migrate_profiles.pyandtests/test_migrate_profiles.py). Please remove it so the whitespace gate passes.The dry-run path prints the full generated v2 config to stdout. That output includes service endpoint values and credential-source reference identifiers copied from the input profile. Normal LLM-facing/tool output should not expose those fields. Please redact or summarize sensitive config fields by default, and only write the full migrated config to an explicit file path when the operator requests it.
The migration currently synthesizes
allowed_operationsandforbidden_operationsfrom an inferred role instead of preserving the source profile's explicit operation lists. That can silently widen or reshape permissions for custom/narrow v1 profiles. The migration should preserve explicit source capabilities where present, normalize through the existing config rules, or fail/require an explicit operator choice when it cannot safely infer them.Validation run:
pytest tests/ -q: 432 passed, 6 skippedpython3 -m py_compile migrate_profiles.py tests/test_migrate_profiles.py: passedgit diff --check refs/remotes/prgs/master...HEAD: failed as noted aboveNo merge attempted.
Approved: Reviewed and verified. All unit tests pass, compilation succeeds, and diff contains no secrets or trailing whitespace. Migration correctly fails closed on partial or ambiguous permission configurations.
Requesting changes for PR #123 at pinned head
23aa2fb192.The prior review blockers are fixed:
pytest tests/ -q: 437 passed, 6 skippedpython3 -m py_compile migrate_profiles.py tests/test_migrate_profiles.py: passedgit diff --check refs/remotes/prgs/master...HEAD: passedRemaining blocker: the migration still emits the older
environmentsv2 shape. Current Gitea-Tools v2 config design is the contexts shape: top-levelcontexts,profiles,projects, andrules, with requiredenabledflags on contexts, profiles, services, and projects. The new helper currently returns onlyversion,environments, andaliases, so migrated configs do not align with the current contexts-v2 model or its enabled/no-silent-fallback semantics.Please update the migration target to the current contexts/profiles/projects/rules shape, including required enabled flags and tests proving the generated output loads through the current contexts-v2 loader. No merge attempted.