Repository navigation
2026 06 10 Security Missing Error Handling
Paulo Gomes da Cruz Junior edited this page Jun 10, 2026
·
1 revision
Category: Security - Error Handling / Robustness
Effort: Low
Priority: Low
Component: frontend/src/components/waste/WasteSearch/WasteSearchFiltersAdvanced/AdvancedFilterClientInput/index.tsx
The onAutoCompleteChange handler makes an API call without any error handling:
onAutoCompleteChange={async (value) =>
(await APIs.forestclient.searchForestClients(value, 0, 10)).map(...)If the API call fails (network error, server error, timeout, etc.), the error will:
- Bubble up to React's rendering, potentially causing a component crash
- Show a raw error message to the user (poor UX)
- Potentially expose sensitive error details (security information disclosure)
- Leave the autocomplete in a broken state
onAutoCompleteChange={async (value) => {
try {
const results = await APIs.forestclient.searchForestClients(value, 0, 10);
return results.map(forestClientAutocompleteResult2CodeDescription);
} catch (error) {
console.error('Failed to fetch forest clients:', error);
return []; // Return empty array to keep UI functional
}
}}const [fetchError, setFetchError] = useState<string | null>(null);
// In the component:
onAutoCompleteChange={async (value) => {
try {
setFetchError(null);
const results = await APIs.forestclient.searchForestClients(value, 0, 10);
return results.map(forestClientAutocompleteResult2CodeDescription);
} catch (error) {
console.error('Failed to fetch forest clients:', error);
setFetchError('Failed to load clients. Please try again.');
return [];
}
}}
// Add error display in JSX:
{fetchError && <InlineNotification kind="error" title="Error" subtitle={fetchError} />}const MAX_RETRIES = 2;
onAutoCompleteChange={async (value, retryCount = 0) => {
try {
const results = await APIs.forestclient.searchForestClients(value, 0, 10);
return results.map(forestClientAutocompleteResult2CodeDescription);
} catch (error) {
console.error('Failed to fetch forest clients:', error);
if (retryCount < MAX_RETRIES) {
return onAutoCompleteChange(value, retryCount + 1);
}
return [];
}
}}frontend/src/components/waste/WasteSearch/WasteSearchFiltersAdvanced/AdvancedFilterClientInput/index.tsx-
frontend/src/services/APIs.ts(check ifsearchForestClientshas its own error handling)
- Test with network errors (use Chrome dev tools to throttle network)
- Test with server 500 errors
- Test with malformed API responses
- Verify that the UI remains functional after errors
- Check that no sensitive error details are shown to users
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository