Skip to content

Bump dependencies#27

Merged
renatomassaro merged 1 commit intomainfrom
bump-dependencies
Aug 24, 2025
Merged

Bump dependencies#27
renatomassaro merged 1 commit intomainfrom
bump-dependencies

Conversation

@renatomassaro
Copy link
Copy Markdown
Owner

@renatomassaro renatomassaro commented Aug 24, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved parameter binding robustness with clearer errors and safer handling to prevent crashes.
  • Chores
    • Updated database driver and coverage tool to newer compatible versions for improved stability and compatibility.
  • Tests
    • Updated tests to reflect the refined binding behavior and added log capture for error scenarios.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 24, 2025

Walkthrough

The SQLite binding API changed from bind/3 to bind/2, removing the connection argument. Repo and tests were updated accordingly. SQLite.bind/2 now wraps Driver.bind with try/rescue and logs ArgumentError, returning {:error, :arguments_wrong_length}. Dependencies were bumped (exqlite ~> 0.33, excoveralls ~> 0.18.5).

Changes

Cohort / File(s) Summary
SQLite bind API refactor
lib/feeb/db/sqlite.ex
Replaced bind/3 with bind/2; added try/rescue around Driver.bind; logs ArgumentError; returns {:error, :arguments_wrong_length}; retained empty-bind 3-arity clause for [].
Call site updates (repo)
lib/feeb/db/repo.ex
Updated calls to use SQLite.bind(stmt, bindings_values) instead of SQLite.bind(conn, stmt, bindings_values) in :query and :prepared_raw paths.
Test updates
test/db/sqlite_test.exs
Adjusted all usages to bind/2; added @tag :capture_log for wrong-arguments test; maintained other APIs unchanged.
Deps bump
mix.exs
exqlite "> 0.23" → "> 0.33"; excoveralls "> 0.18.2" → "> 0.18.5".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller as Repo
  participant SQL as Feeb.DB.SQLite
  participant Driver as Exqlite.Driver
  participant Log as Logger

  Caller->>SQL: prepare(conn, sql)
  SQL-->>Caller: {:ok, stmt}

  Caller->>SQL: bind(stmt, bindings)
  rect rgba(200,230,255,0.3)
    SQL->>Driver: bind(stmt, bindings)
    alt ArgumentError raised
      SQL->>Log: log error (ArgumentError)
      SQL-->>Caller: {:error, :arguments_wrong_length}
    else Success
      SQL-->>Caller: :ok
    end
  end

  opt On successful bind
    Caller->>SQL: all(conn, stmt)
    SQL-->>Caller: {:ok, rows}
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

I thump my paw: two beats, not three,
Bindings hop light as parsley leaves to tea.
If numbers mismatch, I twitch an ear,
Log a squeak—an error’s here.
With deps refreshed and tests in tow,
I bound through fields where queries grow. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bump-dependencies

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (5)
lib/feeb/db/sqlite.ex (1)

44-52: bind/2: good API alignment; refine exception logging and add a typespec.

Catching ArgumentError to normalize into {:error, :arguments_wrong_length} is sensible. Two tweaks recommended:

  • Log the exception with stacktrace for better debuggability.
  • Add a typespec for bind/2 to document the contract.

Apply:

   def bind(stmt, bindings) when is_list(bindings) do
+    @spec bind(stmt(), list()) :: :ok | {:error, :arguments_wrong_length}
     try do
       Driver.bind(stmt, bindings)
     rescue
       e in ArgumentError ->
-        Logger.error(e)
+        Logger.error(Exception.format(:error, e, __STACKTRACE__))
         {:error, :arguments_wrong_length}
     end
   end

Optional: include metadata like the number of args (not their values) to avoid logging PII, e.g., "args_count=#{length(bindings)}".

Also note you kept bind/3 only for the [] case; any remaining 3-arity, non-empty calls will now fail at compile time — which is fine, just ensure none remain (see scan in mix.exs comment).

Would you like me to also add a unit test that verifies we log (captured via @tag :capture_log) and return {:error, :arguments_wrong_length} when passing a wrong number of parameters?

lib/feeb/db/repo.ex (2)

235-241: Switch to SQLite.bind/2 is correct; consider a clearer error for argument-length mismatches.

The with clause now correctly expects :ok from SQLite.bind/2. If bind fails with {:error, :arguments_wrong_length}, it flows to the generic else and logs an opaque error. Consider handling that case explicitly to aid debugging:

     with {:ok, {stmt, stmt_sql}} <- prepare_query(state, query_id, sql),
          true = stmt_sql == sql,
          :ok <- SQLite.bind(stmt, bindings_values),
          {:ok, rows} <- SQLite.all(state.conn, stmt) do
       …
     else
+      {:error, :arguments_wrong_length} = err ->
+        Logger.error("Wrong number of parameters for #{inspect(query_id)} (got #{length(bindings_values)})")
+        {:reply, err, state}
       {:error, _} = err ->
         Logger.error("error: #{inspect(err)}")
         {:reply, err, state}
     end

257-266: Unreachable code after raise "Remove or document usage" in prepared_raw path.

This callback raises unconditionally; the code below will never run and can be deleted to avoid confusion. If you intend to keep it for future work, replace raise with a feature flag or Logger.warning/1 plus an explicit error reply.

   def handle_call({:prepared_raw, raw_sql, bindings_values, opts}, _from, state) do
-    raise "Remove or document usage"
-
-    with {:ok, stmt} <- SQLite.prepare(state.conn, raw_sql),
-         :ok <- SQLite.bind(stmt, bindings_values),
-         {:ok, rows} <- SQLite.all(state.conn, stmt) do
-      schema = Keyword.fetch!(opts, :schema)
-      result = format_custom(:all, schema, rows)
-      {:reply, result, state}
-    else
-      {:error, _} = err ->
-        Logger.error("error: #{inspect(err)}")
-        # TODO: Rollback?
-        {:reply, err, state}
-    end
+    {:reply, {:error, :prepared_raw_disabled}, state}
   end
test/db/sqlite_test.exs (2)

27-32: Good negative test; also update the describe title from bind/3 to bind/2.

The assertions for wrong-length args are correct and @tag :capture_log prevents noisy logs. The section header still says "bind/3" though; update for clarity.

Apply:

-describe "bind/3" do
+describe "bind/2" do

Optional: add one case for "too few args" on a 2-parameter statement to cover both directions.


102-102: Assert the bind/2 result to surface failures earlier.

Non-assertive call can hide a bind failure; assert it for consistency with other tests.

-      SQLite.bind(stmt, ["Jessie", 1])
+      assert :ok = SQLite.bind(stmt, ["Jessie", 1])
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 472957e and c40f57a.

⛔ Files ignored due to path filters (1)
  • mix.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • lib/feeb/db/repo.ex (2 hunks)
  • lib/feeb/db/sqlite.ex (2 hunks)
  • mix.exs (1 hunks)
  • test/db/sqlite_test.exs (2 hunks)
🔇 Additional comments (5)
mix.exs (1)

57-61: All exqlite bind/3 calls removed and mix.lock updated

I’ve confirmed that there are no remaining genuine 3-arity calls to SQLite.bind/3 (all test uses only call the 2-arity API with a list of parameters), and mix.lock pins exqlite at version 0.33.0. This change is safe to merge.

• No SQLite.bind/3 call sites found upon refined search
mix.lock shows "exqlite": "0.33.0" as expected

lib/feeb/db/sqlite.ex (1)

7-8: Requiring Logger is appropriate given new error handling.

No issues. This enables structured logging for the new error path in bind/2.

test/db/sqlite_test.exs (3)

22-25: LGTM: bind/2 happy paths covered for both parameterized and zero-parameter statements.

This validates the new arity on both “SELECT … WHERE id = ?” and “BEGIN”.


38-38: LGTM: one/2 with a bound parameter.

Covers the common success case after bind/2.


44-44: LGTM: one/2 nil path with bind/2.

This exercises the not-found case with the new binding API.

@renatomassaro renatomassaro merged commit e96ba64 into main Aug 24, 2025
3 checks passed
@renatomassaro renatomassaro deleted the bump-dependencies branch August 24, 2025 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant