Skip to content

fix: catch NotFoundException in CrowdinResources for non-app resource IDs#348

Open
evanofficial wants to merge 3 commits intocrowdin:masterfrom
evanofficial:fix/crowdin-resources-non-app-ids
Open

fix: catch NotFoundException in CrowdinResources for non-app resource IDs#348
evanofficial wants to merge 3 commits intocrowdin:masterfrom
evanofficial:fix/crowdin-resources-non-app-ids

Conversation

@evanofficial
Copy link
Copy Markdown

@evanofficial evanofficial commented Apr 9, 2026

Fixes #347

When WebView (or other system components) call `getString()` with their own internal resource IDs, `CrowdinResources.getResourceEntryName()` throws `Resources$NotFoundException` because those IDs don't exist in the host app's resource table.

Wrap the resource lookup in a try-catch for `Resources.NotFoundException` and fall back to `super.getString()` when the resource ID is not from the host app.


Note

Medium Risk
Touches the core Resources wrapper used throughout the app; while the change is mainly defensive exception handling, incorrect fallbacks could subtly alter string/plural resolution behavior in edge cases.

Overview
Prevents crashes when system components (e.g., WebView) call CrowdinResources with non-app resource IDs by catching Resources.NotFoundException in getString, getString(vararg), getStringArray, and getText, and falling back to super implementations.

Also hardens repository/plural handling by skipping reserve-resource persistence when an entry name can’t be resolved (savePluralToCopy) and returning null from repository lookups (getStringArrayFromRepository, getPluralFromRepository) when the ID isn’t found.

Reviewed by Cursor Bugbot for commit 37e557a. Bugbot is set up for automated code reviews on this repo. Configure here.

… IDs

Wrap getResourceEntryName() calls in try-catch so that resource IDs from
system components (e.g. WebView/Chromium) that don't exist in the host
app's resource table fall back to the parent Resources implementation
instead of crashing with Resources$NotFoundException.
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 37e557a. Configure here.

formattedString
} catch (_: NotFoundException) {
super.getText(id, default)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quantity methods lack NotFoundException catch unlike other overrides

Medium Severity

The getQuantityText and getQuantityString methods lack the try-catch (NotFoundException) wrapper present in other Resources overrides. While their internal helpers now safely return null for non-app IDs, the fallback calls to the base res.getQuantityText or res.getQuantityString can still throw NotFoundException, causing crashes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 37e557a. Configure here.

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 9, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

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.

Crowdin CrowdinResources crashes on non-app resource IDs

1 participant