Skip to content

Commit fabdff6

Browse files
committed
refactor(notion-fetch): add safety improvements to filterChangedPages
Add documentation and safety checks based on Phase 2 review findings: 1. Add NOTE in JSDoc clarifying function is currently unused - Points to actual implementation in generateBlocks.ts:704-711 - Explains function is maintained for testing and future refactoring - Prevents confusion about why function exists but isn't called 2. Add empty path validation check - Safety guard: if getFilePath returns empty/whitespace, regenerate - Prevents edge case where empty path could cause issues - Fail-safe approach: when in doubt, regenerate Changes are defensive improvements that make the function more robust without changing its core behavior. Empty path validation prevents potential edge case identified in review. Related: PHASE_2_REVIEW.md recommendations #1 and #2
1 parent 85c7d09 commit fabdff6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/notion-fetch/pageMetadataCache.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ export function determineSyncMode(
173173
* Filter pages to only those that need processing.
174174
* Returns pages that are new or have been edited since last sync.
175175
*
176+
* NOTE: This function is currently not used in production code.
177+
* The inline needsProcessing logic in generateBlocks.ts (lines 704-711)
178+
* performs the same checks. This function is maintained for testing and
179+
* potential future refactoring to avoid code duplication.
180+
*
176181
* @param pages - All pages from Notion
177182
* @param cache - Loaded page metadata cache
178183
* @param options - Optional configuration
@@ -211,6 +216,12 @@ export function filterChangedPages<
211216
// even if their Notion timestamp hasn't changed yet
212217
if (options?.getFilePath) {
213218
const currentPath = options.getFilePath(page);
219+
220+
// Safety: If path is empty/invalid, regenerate to be safe
221+
if (!currentPath || currentPath.trim() === "") {
222+
return true;
223+
}
224+
214225
if (!cached.outputPaths?.includes(currentPath)) {
215226
return true;
216227
}

0 commit comments

Comments
 (0)