Conversation
📝 WalkthroughWalkthroughEndPoint 프로토콜의 queryParameters 속성 타입을 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Network/EndPoint/EndPoint.swift`:
- Around line 48-51: EndPoint에서 URLQueryItem을 만들 때 String(describing: $0.value)로
Optional을 그대로 문자열화하면 "Optional(...)" 또는 "nil"이 전송되니, Optional을 안전하게 처리하도록 변경하세요:
파라미터 딕셔너리에서 nil 값을 필터링(compactMap)하거나 각 값에 대해 value.map { String($0) } 또는
"\(unwrapped)" 방식으로 언래핑한 문자열을 사용해 URLQueryItem(name: $0.key, value:
unwrappedString)으로 생성하도록 수정을 적용(참조심볼: URLQueryItem, $0.key, $0.value,
EndPoint.swift).
| URLQueryItem( | ||
| name: $0.key, | ||
| value: String(describing: $0.value) | ||
| ) |
There was a problem hiding this comment.
String(describing:)의 Optional 처리 동작에 주의하세요
String(describing:)은 Optional 값을 전달받으면 "Optional(123)" 또는 "nil" 형태의 문자열을 생성합니다. 이로 인해 예상치 못한 쿼리 스트링이 서버로 전송될 수 있습니다.
예시:
let value: Int? = 123
String(describing: value) // "Optional(123)" ❌
"\(value!)" // "123" ✅ (단, 강제 언래핑 필요)🛠️ Optional 안전 처리를 위한 수정 제안
if let queryParameters {
- urlComponents.queryItems = queryParameters.map {
- URLQueryItem(
- name: $0.key,
- value: String(describing: $0.value)
- )
- }
+ urlComponents.queryItems = queryParameters.compactMap { key, value in
+ if case Optional<Any>.none = value {
+ return nil
+ }
+ let stringValue: String
+ if let optional = value as? any OptionalProtocol {
+ stringValue = optional.wrappedDescription
+ } else {
+ stringValue = "\(value)"
+ }
+ return URLQueryItem(name: key, value: stringValue)
+ }
}또는 더 간단하게 "\($0.value)"를 사용하되, 호출하는 쪽에서 Optional이 아닌 값만 전달하도록 문서화하는 방법도 있습니다:
- value: String(describing: $0.value)
+ value: "\($0.value)"🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Network/EndPoint/EndPoint.swift` around lines
48 - 51, EndPoint에서 URLQueryItem을 만들 때 String(describing: $0.value)로 Optional을
그대로 문자열화하면 "Optional(...)" 또는 "nil"이 전송되니, Optional을 안전하게 처리하도록 변경하세요: 파라미터
딕셔너리에서 nil 값을 필터링(compactMap)하거나 각 값에 대해 value.map { String($0) } 또는
"\(unwrapped)" 방식으로 언래핑한 문자열을 사용해 URLQueryItem(name: $0.key, value:
unwrappedString)으로 생성하도록 수정을 적용(참조심볼: URLQueryItem, $0.key, $0.value,
EndPoint.swift).
🔗 연결된 이슈
📄 작업 내용