fix (cli): adding checks for fly cli name length, replacing underscore, and adding checks for duplicate field names #722
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.
Greptile Overview
Greptile Summary
Added validation safeguards to prevent Fly.io deployment failures and schema definition errors.
Key Changes:
fly.tomlfiles before deployment to prevent conflictsImportant Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant User participant FlyManager participant FlyAPI participant SchemaAnalyzer Note over User,SchemaAnalyzer: Fly.io Deployment Flow User->>FlyManager: init_app(instance_name, config) FlyManager->>FlyManager: app_name() - sanitize underscores to hyphens FlyManager->>FlyManager: Check app_name.len() <= 32 alt Name too long FlyManager-->>User: Error: exceeds MAX_APP_NAME_LENGTH end FlyManager->>FlyManager: read_app_name_from_fly_toml() alt fly.toml exists FlyManager->>FlyAPI: app_exists(existing_app_name) FlyAPI-->>FlyManager: true/false alt App exists FlyManager-->>User: Error: fly.toml app already exists end end FlyManager->>FlyAPI: app_exists(app_name) FlyAPI-->>FlyManager: true/false alt App exists FlyManager-->>User: Error: target app already exists end FlyManager->>FlyAPI: Create app FlyAPI-->>User: Success Note over User,SchemaAnalyzer: Schema Validation Flow User->>SchemaAnalyzer: Define schema with fields SchemaAnalyzer->>SchemaAnalyzer: Initialize seen_fields HashSet loop For each field SchemaAnalyzer->>SchemaAnalyzer: lowercase field name SchemaAnalyzer->>SchemaAnalyzer: seen_fields.insert(lower_name) alt Duplicate detected SchemaAnalyzer->>SchemaAnalyzer: push_schema_err(E109) end SchemaAnalyzer->>SchemaAnalyzer: Check reserved names SchemaAnalyzer->>SchemaAnalyzer: Check field type validity end SchemaAnalyzer-->>User: Validation complete with diagnostics