Fix crash in DisambiguationExtractor by adding safe fallback for missing language configurations#838
Conversation
…lse for language config
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo small edits: a defensive map lookup in DisambiguationExtractor now uses getOrElse with " (disambiguation)" as a fallback; the CI snapshot deploy step adds the Maven flag Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip Migrating from UI to YAML configuration.Use the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/src/main/scala/org/dbpedia/extraction/mappings/DisambiguationExtractor.scala (1)
25-25: Surface missing language configs instead of silently defaulting to English.This fixes the crash, but it also hides config gaps: if
language.wikiCodeis absent fromDisambiguationExtractorConfig.disambiguationTitlePartMap(core/src/main/scala/org/dbpedia/extraction/config/mappings/DisambiguationExtractorConfig.scala:4-40), title normalization now assumes the English suffix, which can quietly miss matches for languages that use a different disambiguation marker. A warning or metric here would keep the fallback while making incomplete language coverage visible.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/src/main/scala/org/dbpedia/extraction/mappings/DisambiguationExtractor.scala` at line 25, The code currently silently falls back to the English suffix when DisambiguationExtractorConfig.disambiguationTitlePartMap lacks an entry for language.wikiCode; update the logic around replaceString to log or emit a metric when a language key is missing while keeping the existing getOrElse fallback: check DisambiguationExtractorConfig.disambiguationTitlePartMap.contains(language.wikiCode) (or examine the Option returned by get) prior to assigning replaceString, and if absent call the project logger/metrics recorder with the missing language.wikiCode and the fact that the English default " (disambiguation)" will be used; keep the existing variable name replaceString and the same default value so behavior is unchanged except for the added warning/metric.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@core/src/main/scala/org/dbpedia/extraction/mappings/DisambiguationExtractor.scala`:
- Line 25: The code currently silently falls back to the English suffix when
DisambiguationExtractorConfig.disambiguationTitlePartMap lacks an entry for
language.wikiCode; update the logic around replaceString to log or emit a metric
when a language key is missing while keeping the existing getOrElse fallback:
check
DisambiguationExtractorConfig.disambiguationTitlePartMap.contains(language.wikiCode)
(or examine the Option returned by get) prior to assigning replaceString, and if
absent call the project logger/metrics recorder with the missing
language.wikiCode and the fact that the English default " (disambiguation)" will
be used; keep the existing variable name replaceString and the same default
value so behavior is unchanged except for the added warning/metric.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 76548f76-c77d-49c6-a3af-7325dcbe21a9
📒 Files selected for processing (1)
core/src/main/scala/org/dbpedia/extraction/mappings/DisambiguationExtractor.scala
|
|
Hi I had fixed the Maven Credentials that was giving the error!! |



Fix: Safe Language Config Lookup in
DisambiguationExtractorProblem
Direct map access caused a runtime crash when a language code was missing from
disambiguationTitlePartMap:Solution
Replaced with
.getOrElseto fall back to" (disambiguation)"when a language config is absent:Testing
NoSuchElementExceptionthrown for missing language codes" (disambiguation)"applied correctlySummary by CodeRabbit