Skip to content

enh(Notion) - improve logging on parents updates #11407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions connectors/src/connectors/notion/lib/parents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ import {
import { dataSourceConfigFromConnector } from "@connectors/lib/api/data_source_config";
import { updateDataSourceDocumentParents } from "@connectors/lib/data_sources";
import { NotionDatabase, NotionPage } from "@connectors/lib/models/notion";
import logger from "@connectors/logger/logger";
import parentLogger from "@connectors/logger/logger";
import { ConnectorResource } from "@connectors/resources/connector_resource";
import type { ModelId } from "@connectors/types";
import { cacheWithRedis } from "@connectors/types";

const logger = parentLogger.child({ provider: "notion" });

/** Compute the parents field for a notion pageOrDb See the [Design
* Doc](https://www.notion.so/dust-tt/Engineering-e0f834b5be5a43569baaf76e9c41adf2?p=3d26536a4e0a464eae0c3f8f27a7af97&pm=s)
* and the field documentation [in
* core](https://github.com/dust-tt/dust/blob/main/core/src/data_sources/data_source.rs)
* for relevant details
*
* @param memoizationKey optional key to control memoization of this function (not actually used by the functio)
* @param memoizationKey optional key to control memoization of this function (not effectively used by the function)
*
*/
async function _getParents(
Expand Down Expand Up @@ -79,7 +81,7 @@ async function _getParents(
pageOrDbId,
parentId: pageOrDb.parentId,
},
"getParents parentId is undefined"
"getParents: parentId is undefined"
);
throw new Error("getParent parentId is undefined");
}
Expand All @@ -91,7 +93,7 @@ async function _getParents(
seen,
parentId: pageOrDb.parentId,
},
"getParents infinite loop"
"getParents: Infinite loop"
);
return parents.concat(seen);
}
Expand Down Expand Up @@ -150,7 +152,7 @@ export async function updateAllParentsFields(
connectorId,
pageIdsToUpdateCount: pageAndDatabaseIdsToUpdate.size,
},
"Updating parents field for pages and databases"
"updateAllParentsFields: Updating parents field for pages and databases"
);

// Update everybody's parents field. Use of a memoization key to control
Expand Down Expand Up @@ -178,6 +180,7 @@ export async function updateAllParentsFields(
if (page && page.parentId !== "workspace") {
logger.warn(
{
connectorId,
parents,
parentType: page.parentType,
parentId: page.parentId,
Expand All @@ -192,6 +195,7 @@ export async function updateAllParentsFields(
if (database && database.parentId !== "workspace") {
logger.warn(
{
connectorId,
parents,
parentType: database?.parentType,
parentId: database?.parentId,
Expand Down