Skip to content

Commit 8361f37

Browse files
authored
fix(ios): omit deep-link URLs from logs (#134738)
1 parent 935c16b commit 8361f37

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎apps/ios/Sources/Model/NodeAppModel.swift‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10034,8 +10034,7 @@ extension NodeAppModel {
1003410034
private func handleAgentDeepLink(_ link: AgentDeepLink, originalURL: URL) async {
1003510035
let message = link.message.trimmingCharacters(in: .whitespacesAndNewlines)
1003610036
guard !message.isEmpty else { return }
10037-
self.deepLinkLogger.info(
10038-
"agent deep link messageChars=\(message.count) url=\(originalURL.absoluteString, privacy: .public)")
10037+
self.deepLinkLogger.info("agent deep link messageChars=\(message.count, privacy: .public)")
1003910038

1004010039
if message.count > IOSDeepLinkAgentPolicy.maxMessageChars {
1004110040
self.recordShareEvent("Rejected: message too large (\(message.count) chars).")

‎apps/ios/Tests/NodeAppModelInvokeTests.swift‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7575,6 +7575,16 @@ private final class TimingOutDeviceStatusService: DeviceStatusServicing {
75757575
#expect(appModel.lastShareEventText.contains("gateway not connected"))
75767576
}
75777577

7578+
@Test func `agent deep link logging excludes the original URL`() throws {
7579+
let source = try String(contentsOf: Self.nodeAppModelSourceURL(), encoding: .utf8)
7580+
let start = try #require(source.range(of: "private func handleAgentDeepLink("))
7581+
let end = try #require(
7582+
source.range(of: "private func effectiveAgentDeepLinkForPrompt(", range: start.upperBound..<source.endIndex))
7583+
let handler = String(source[start.lowerBound..<end.lowerBound])
7584+
7585+
#expect(!handler.contains("originalURL.absoluteString, privacy: .public"))
7586+
}
7587+
75787588
@Test @MainActor func `handle deep link records oversized message rejection`() async throws {
75797589
let appModel = NodeAppModel()
75807590
let msg = String(repeating: "a", count: 20001)
@@ -7726,4 +7736,11 @@ private final class TimingOutDeviceStatusService: DeviceStatusServicing {
77267736
try await appModel.sendVoiceTranscript(text: "hello", sessionKey: "main")
77277737
}
77287738
}
7739+
7740+
private static func nodeAppModelSourceURL() -> URL {
7741+
URL(fileURLWithPath: #filePath)
7742+
.deletingLastPathComponent()
7743+
.deletingLastPathComponent()
7744+
.appendingPathComponent("Sources/Model/NodeAppModel.swift")
7745+
}
77297746
}

0 commit comments

Comments
 (0)