Fix/config import validation issues#18
Merged
rockythorn merged 4 commits intofeature/config-and-processing-refactorfrom Nov 13, 2025
Merged
Fix/config import validation issues#18rockythorn merged 4 commits intofeature/config-and-processing-refactorfrom
rockythorn merged 4 commits intofeature/config-and-processing-refactorfrom
Conversation
This commit addresses two validation issues that prevented importing
configuration files exported from production:
1. Export serializer converting version numbers to floats:
- The _json_serializer in admin_supported_products.py was converting
all Decimal types to float, including version numbers
- Version numbers (match_major_version, match_minor_version) should
be integers, not floats
- Updated serializer to check if Decimal is a whole number and
convert to int, preserving proper type semantics
2. Name validation rejecting parentheses:
- Production database contains legacy products with names like
"Rocky Linux 8.5 x86_64 (Legacy)"
- Validation pattern only allowed: letters, numbers, spaces, dots,
hyphens, and underscores
- Updated NAME_PATTERN to allow parentheses for legacy product naming
- Updated error message to reflect allowed characters
These changes ensure that configurations exported from production can
be successfully imported into development environments without manual
data cleanup.
Update test expectations to match the new behavior where whole number Decimal values are serialized as integers instead of floats. This aligns with the change to _json_serializer that preserves integer types for version numbers and other integer values.
trinity-q
approved these changes
Nov 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two validation issues that prevented importing configuration files exported from Apollo's production database. The fixes ensure that supported product configurations can be exported and imported between environments (production → development, staging, etc.) without manual data cleanup.
Problem Statement
1. Export serializer converting version numbers to floats
The JSON export function was converting all
Decimaldatabase types to floats, including version numbers (match_major_version,match_minor_version). When these exported configs were imported back, the validation layer rejected float version numbers because it expects integers.Example issue:
Impact:
9.0→9before import2. Name validation rejecting parentheses
Production database contains legacy product entries with parentheses in names (e.g., "Rocky Linux 8.5 x86_64 (Legacy)"). The validation regex didn't allow parentheses, causing import failures.
Example issue:
Impact:
Changes
1. Fix Decimal to int serialization
Updated
_json_serializer()to detect whole numbers and convert to int instead of float:Before:
After:
Result:
{ "name": "Rocky Linux 9 x86_64", "match_major_version": 9, // integer (CORRECT) "match_minor_version": null }2. Allow parentheses in name validation
Updated
NAME_PATTERNregex to include parentheses:Before:
After:
Updated error message:
3. Update tests
Updated test expectations to match new integer serialization behavior:
File:
apollo/tests/test_admin_routes_supported_products.pyChanged test assertions from expecting float to expecting int:
How It Fits Into Apollo
Apollo's configuration management workflow:
Why these fixes matter:
Validation Example
Before this PR
Export from production:
Exported JSON:
{ "name": "Rocky Linux 8.5 x86_64 (Legacy)", "match_variant": "Red Hat Enterprise Linux", "match_major_version": 8.0, "match_minor_version": 5.0, "match_arch": "x86_64" }Import to staging:
curl -X POST -F "[email protected]" https://apollo.staging/api/admin/supported_products/importResult: ❌ FAILS
{ "errors": [ "Name can only contain letters, numbers, spaces, dots, hyphens, and underscores", "match_major_version must be an integer, got float" ] }After this PR
Export from production:
Exported JSON:
{ "name": "Rocky Linux 8.5 x86_64 (Legacy)", "match_variant": "Red Hat Enterprise Linux", "match_major_version": 8, "match_minor_version": 5, "match_arch": "x86_64" }Import to staging:
curl -X POST -F "[email protected]" https://apollo.staging/api/admin/supported_products/importResult: ✅ SUCCESS
{ "message": "Configuration imported successfully", "products_created": 1 }Testing
Unit tests:
test_admin_routes_supported_products.pyto expect integer version numbersIntegration validation:
Test coverage:
Deployment Notes
Files Changed
Use Cases
Disaster Recovery
Staging Environment Sync
Bulk Configuration Updates
Version Control
Related Issues