Skip to content

feat: add startup and document save failure logs for improved debugging#46

Open
anshuman9468 wants to merge 1 commit intodbpedia:masterfrom
anshuman9468:add-logging-startup-save-errors
Open

feat: add startup and document save failure logs for improved debugging#46
anshuman9468 wants to merge 1 commit intodbpedia:masterfrom
anshuman9468:add-logging-startup-save-errors

Conversation

@anshuman9468
Copy link

@anshuman9468 anshuman9468 commented Feb 21, 2026

Adds console logs during startup (local dev context caching) and when document save operations fail, particularly for remote context loading errors.

This improves debugging visibility and speeds up issue identification.

Summary by CodeRabbit

  • Chores
    • Enhanced logging infrastructure across core services to improve operational visibility and error diagnostics.
    • Improved error reporting for file operations and RDF parsing with enhanced logging on failures.

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

📝 Walkthrough

Walkthrough

This PR adds observability through SLF4J logging to three core components: ApiImpl logs file commit failures, JettyLauncher reports git directory configuration status, and SparqlClient logs RDF parsing errors.

Changes

Cohort / File(s) Summary
Logging Infrastructure
src/main/scala/org/dbpedia/databus/ApiImpl.scala
Added SLF4J logger initialization and wrapped commitSeveralFiles call with error logging that guards against logging failures before propagating the exception.
Configuration Reporting
src/main/scala/org/dbpedia/databus/JettyLauncher.scala
Added logging to report whether a local git directory is configured, displaying either the absolute path or a message indicating remote git API may be used.
Error Handling
src/main/scala/org/dbpedia/databus/SparqlClient.scala
Added SLF4J logger and wrapped RDFDataMgr.read() with try-catch to log parse failures including the input language name before rethrowing.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding startup logs and document save failure logs for debugging purposes, which aligns with all three modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! 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.

🧹 Nitpick comments (3)
src/main/scala/org/dbpedia/databus/ApiImpl.scala (1)

173-177: Drop the defensive inner try-catch around log.error — SLF4J does not throw.

SLF4J's contract guarantees that logging calls do not propagate exceptions. Wrapping log.error(...) in a separate try-catch adds noise without providing any real protection.

♻️ Proposed fix
      .recoverWith {
        case err: Throwable =>
-          try {
-            log.error(s"Failed to save files for user '$username' (${fullFilenamesAndData.keys.mkString(",")})", err)
-          } catch {
-            case _: Throwable => // ignore logging failures
-          }
+          log.error(s"Failed to save files for user '$username' (${fullFilenamesAndData.keys.mkString(",")})", err)
          Failure(err)
      }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/scala/org/dbpedia/databus/ApiImpl.scala` around lines 173 - 177,
Remove the redundant defensive inner try-catch around the logging call in
ApiImpl.scala: instead of wrapping log.error(s"Failed to save files for user
'$username' (${fullFilenamesAndData.keys.mkString(",")})", err) in a try { ... }
catch { case _: Throwable => ... }, just call log.error(...) directly (no
surrounding try-catch). This removes noise because SLF4J guarantees logging
calls won't throw; keep the existing error message, variables (username,
fullFilenamesAndData) and the err parameter unchanged.
src/main/scala/org/dbpedia/databus/JettyLauncher.scala (1)

42-47: Replace isDefined + .get with idiomatic pattern matching.

Calling .get on an Option — even when guarded by isDefined — is non-idiomatic in Scala and suppresses the safe-access benefit of Option. A match expression avoids .get entirely.

♻️ Proposed fix
-    if (config.gitLocalDir.isDefined) {
-      log.info(s"Using local git directory: ${config.gitLocalDir.get.toAbsolutePath}")
-      log.info("Attempting to cache local development context (if present)")
-    } else {
-      log.info("No local git directory configured; using remote git API (if configured)")
-    }
+    config.gitLocalDir match {
+      case Some(dir) =>
+        log.info(s"Using local git directory: ${dir.toAbsolutePath}")
+        log.info("Attempting to cache local development context (if present)")
+      case None =>
+        log.info("No local git directory configured; using remote git API (if configured)")
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/scala/org/dbpedia/databus/JettyLauncher.scala` around lines 42 - 47,
Replace the isDefined + .get pattern on config.gitLocalDir with safe Option
handling: match on config.gitLocalDir (or use foreach/fold) and call log.info
with the path inside the Some(path) branch, otherwise use the existing else
message; update the block containing config.gitLocalDir, the two log.info calls
and remove .get to avoid unsafe access.
src/main/scala/org/dbpedia/databus/SparqlClient.scala (1)

160-162: Pass the Throwable as the second argument to log.error to capture the stack trace.

The current call constructs a string with e.getMessage, which only logs the exception message — losing the full stack trace. SLF4J recognises a trailing Throwable argument and appends the complete stack trace, which is far more useful for debugging. Note that e.getMessage can also be null for some Throwable subclasses, producing the literal string "null" in the log. Both issues are fixed by using the two-argument form, consistent with ApiImpl.scala Line 174.

♻️ Proposed fix
-        log.error(s"Failed to parse input as ${lang.getName}: ${e.getMessage}")
+        log.error(s"Failed to parse input as ${lang.getName}", e)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/scala/org/dbpedia/databus/SparqlClient.scala` around lines 160 -
162, The log call in the exception handler inside SparqlClient.scala's parsing
block (the `case e: Throwable` branch) only interpolates e.getMessage and thus
loses the stack trace; change the call to pass the Throwable as the second
argument to SLF4J (use the two-argument form like log.error("Failed to parse
input as {}: {}", lang.getName, e.getMessage, e) or equivalent) so the full
stack trace is recorded—update the `case e: Throwable` handler accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/scala/org/dbpedia/databus/ApiImpl.scala`:
- Around line 173-177: Remove the redundant defensive inner try-catch around the
logging call in ApiImpl.scala: instead of wrapping log.error(s"Failed to save
files for user '$username' (${fullFilenamesAndData.keys.mkString(",")})", err)
in a try { ... } catch { case _: Throwable => ... }, just call log.error(...)
directly (no surrounding try-catch). This removes noise because SLF4J guarantees
logging calls won't throw; keep the existing error message, variables (username,
fullFilenamesAndData) and the err parameter unchanged.

In `@src/main/scala/org/dbpedia/databus/JettyLauncher.scala`:
- Around line 42-47: Replace the isDefined + .get pattern on config.gitLocalDir
with safe Option handling: match on config.gitLocalDir (or use foreach/fold) and
call log.info with the path inside the Some(path) branch, otherwise use the
existing else message; update the block containing config.gitLocalDir, the two
log.info calls and remove .get to avoid unsafe access.

In `@src/main/scala/org/dbpedia/databus/SparqlClient.scala`:
- Around line 160-162: The log call in the exception handler inside
SparqlClient.scala's parsing block (the `case e: Throwable` branch) only
interpolates e.getMessage and thus loses the stack trace; change the call to
pass the Throwable as the second argument to SLF4J (use the two-argument form
like log.error("Failed to parse input as {}: {}", lang.getName, e.getMessage, e)
or equivalent) so the full stack trace is recorded—update the `case e:
Throwable` handler accordingly.

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