feat(ip): normalize IPv4-mapped IPv6 addresses#29
Conversation
📝 WalkthroughWalkthrough新しい IP 正規化ユーティリティ ChangesIP 正規化とロギング統合
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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: 2
🧹 Nitpick comments (1)
src/util/ip.test.ts (1)
5-33: ⚡ Quick win境界値(
undefinedと空文字)のテストを追加してください。今回の機能目的にある未定義値処理の回帰防止のため、
normalizeIpAddress(undefined)とnormalizeIpAddress("")の期待値を固定するテストを追加するのが安全です。追加入力例
Deno.test("normalizeIpAddress keeps normal IPv6 as-is", () => { assertEquals(normalizeIpAddress("::1"), "::1"); assertEquals(normalizeIpAddress("fc00:db8::1"), "fc00:db8::1"); }); + +Deno.test("normalizeIpAddress handles undefined and empty string", () => { + assertEquals(normalizeIpAddress(undefined), undefined); + assertEquals(normalizeIpAddress(""), ""); +});🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/util/ip.test.ts` around lines 5 - 33, Add a new Deno.test that asserts normalizeIpAddress handles undefined and empty-string inputs to prevent regressions: call normalizeIpAddress(undefined) and assertEquals the result to undefined, and call normalizeIpAddress("") and assertEquals the result to "" (use the existing test pattern and the normalizeIpAddress symbol to locate where to add the test).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/service/logging/formatter.ts`:
- Around line 63-65: The footer currently inserts "undefined" when
normalizeIpAddress(info.remote.address) returns undefined; update the formatting
logic used in the footer (and the similar occurrence at the other block) to fall
back to "Unknown" when info.remote.address is missing or normalizeIpAddress
returns a falsy/undefined value — i.e., compute a safeIp =
normalizeIpAddress(info.remote?.address) || "Unknown" and use safeIp in the text
template (references: normalizeIpAddress, info.remote.address, formatTimestamp).
In `@src/util/ip.ts`:
- Line 5: The current guard treats empty string as undefined because it uses `if
(!address) return;`; change this to only early-return for actual undefined by
replacing the condition with a strict undefined check (e.g., `address ===
undefined`) so that "" is not treated as missing; update the guard that
references the `address` variable in this module (`src/util/ip.ts`) accordingly.
---
Nitpick comments:
In `@src/util/ip.test.ts`:
- Around line 5-33: Add a new Deno.test that asserts normalizeIpAddress handles
undefined and empty-string inputs to prevent regressions: call
normalizeIpAddress(undefined) and assertEquals the result to undefined, and call
normalizeIpAddress("") and assertEquals the result to "" (use the existing test
pattern and the normalizeIpAddress symbol to locate where to add the test).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 73311c77-79e4-42fd-be0a-564edaff433f
📒 Files selected for processing (3)
src/service/logging/formatter.tssrc/util/ip.test.tssrc/util/ip.ts
Summary by CodeRabbit
リリースノート
New Features
Tests