Skip to content

fix: add log for ipv4 projects#1748

Merged
filipecabaco merged 2 commits intomainfrom
fix/log-ipv4-detected
Mar 11, 2026
Merged

fix: add log for ipv4 projects#1748
filipecabaco merged 2 commits intomainfrom
fix/log-ipv4-detected

Conversation

@filipecabaco
Copy link
Member

What kind of change does this PR introduce?

add log for ipv4 projects

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Added IPv4 detection logging to improve system observability and diagnostics.

Walkthrough

A logging statement was added to the from_settings function in the database module to emit a warning when IPv4 is detected for a project, including the project host information. A corresponding test case was added to verify that this warning is properly logged with the expected metadata.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/realtime/database.ex`:
- Around line 68-69: The warning currently logs unconditionally; change the
logic around detect_ip_version to only call log_warning("IpV4Detected", "IPv4
detected for project", project: settings["db_host"]) when the returned addrtype
variable equals :inet. Locate the detect_ip_version call and the subsequent
log_warning invocation in the same block, add a conditional check (addrtype ==
:inet) before calling log_warning so IPv6 results do not trigger the message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: efc433ec-2201-4e2b-90a2-85b18d8f4f2a

📥 Commits

Reviewing files that changed from the base of the PR and between 77ad883 and 31606bf.

📒 Files selected for processing (2)
  • lib/realtime/database.ex
  • test/realtime/database_test.exs

Comment on lines +68 to +69
{:ok, addrtype} = detect_ip_version(settings["db_host"])
log_warning("IpV4Detected", "IPv4 detected for project", project: settings["db_host"])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Bug: Warning is logged unconditionally regardless of IP version detected.

The log_warning("IpV4Detected", ...) fires for every connection, including IPv6. It should only log when addrtype == :inet.

Proposed fix
     {:ok, addrtype} = detect_ip_version(settings["db_host"])
-    log_warning("IpV4Detected", "IPv4 detected for project", project: settings["db_host"])
+    if addrtype == :inet do
+      log_warning("IpV4Detected", "IPv4 detected for project", project: settings["db_host"])
+    end
     ssl = if default_ssl_param(settings), do: [verify: :verify_none], else: false
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/realtime/database.ex` around lines 68 - 69, The warning currently logs
unconditionally; change the logic around detect_ip_version to only call
log_warning("IpV4Detected", "IPv4 detected for project", project:
settings["db_host"]) when the returned addrtype variable equals :inet. Locate
the detect_ip_version call and the subsequent log_warning invocation in the same
block, add a conditional check (addrtype == :inet) before calling log_warning so
IPv6 results do not trigger the message.

Copy link
Contributor

@chasers chasers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coderabbit looks correct here

@filipecabaco filipecabaco merged commit 924dcc4 into main Mar 11, 2026
10 checks passed
@filipecabaco filipecabaco deleted the fix/log-ipv4-detected branch March 11, 2026 13:32
@kiwicopple
Copy link
Member

🎉 This PR is included in version 2.78.13 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants