-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Severity: 🟡 Minor
File: Sources/BushelFoundation/DataSourceMetadata.swift:60
PR: #126
Issue
The recordName computed property is composed from sourceName and recordTypeName without validation. CloudKit record names have strict requirements:
- Must be ASCII-only
- No longer than 255 characters
- Cannot contain empty strings
While current test values are well-formed, the code should validate that sourceName and recordTypeName meet these constraints.
Current Code
public var recordName: String {
"metadata-\(sourceName)-\(recordTypeName)"
}Recommendation
Add input validation during initialization to ensure:
- Neither
sourceNamenorrecordTypeNameis empty - Each string's
unicodeScalarsare ASCII (e.g.,unicodeScalars.allSatisfy { $0.isASCII }) - The full
recordNamedoes not exceed 255 bytes/characters
Implement this in the DataSourceMetadata initializer and fail fast (throw a validation error or use precondition) so invalid values cannot be instantiated.
CodeRabbit Suggestion
In @Sources/BushelFoundation/DataSourceMetadata.swift around lines 57-60,
Validate sourceName and recordTypeName at construction instead of only in
recordName: ensure neither is empty, each string's unicodeScalars are ASCII
(e.g. unicodeScalars.allSatisfy { $0.isASCII }), and that the full recordName
computed in recordName ("metadata-\(sourceName)-\(recordTypeName)") does not
exceed 255 bytes/characters; implement this in the DataSourceMetadata
initializer (init(sourceName:recordTypeName:)) and fail fast (throw a validation
error or use precondition) so invalid values cannot be instantiated, and keep
the computed var recordName as-is.
Source: CodeRabbit AI review of PR #126
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request