From 7906e3407c2be6daf3b9682dcdb02f1a051ebe6e Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:20:47 +0000 Subject: [PATCH 1/4] update dataRefDr for ceramic, improve logging, add manifest entry check --- desci-server/package.json | 2 +- desci-server/src/scripts/dataRefDoctor.ts | 83 ++++++++++++++++------- desci-server/src/utils/dataRefTools.ts | 37 ++++++++-- 3 files changed, 89 insertions(+), 33 deletions(-) diff --git a/desci-server/package.json b/desci-server/package.json index f2a664a6a..12f6d71fe 100755 --- a/desci-server/package.json +++ b/desci-server/package.json @@ -14,7 +14,7 @@ "script:upgrade-manifests": "debug=* node --no-warnings --enable-source-maps --loader ts-node/esm ./src/scripts/upgradeManifests.ts", "script:test-upgrade-manifests": "debug=* node --no-warnings --enable-source-maps --loader ts-node/esm ./src/scripts/testUpgradeManifests.ts", "script:fill-research-fields": "debug=* node --no-warnings --enable-source-maps --loader ts-node/esm ./src/scripts/fill-research-fields.ts", - "script:fix-data-refs": "debug=* node --no-warnings --enable-source-maps --loader ts-node/esm ./src/scripts/dataRefDoctor.ts", + "script:fix-data-refs": "debug=* node --inspect=0.0.0.0:9277 --no-warnings --enable-source-maps --loader ts-node/esm ./src/scripts/dataRefDoctor.ts", "script:active-users": "debug=* node --no-warnings --enable-source-maps --loader ts-node/esm ./src/scripts/activeUsers.ts", "script:invalidate-redis-cache": "debug=* node --no-warnings --enable-source-maps --loader ts-node/esm ./src/scripts/invalidate-redis-cache.ts", "script:increase-base-drive-storage": "debug=* node --no-warnings --enable-source-maps --loader ts-node/esm ./src/scripts/increase-base-drive-storage.ts", diff --git a/desci-server/src/scripts/dataRefDoctor.ts b/desci-server/src/scripts/dataRefDoctor.ts index 3b6490a29..e5617cb13 100644 --- a/desci-server/src/scripts/dataRefDoctor.ts +++ b/desci-server/src/scripts/dataRefDoctor.ts @@ -7,7 +7,7 @@ import { getSizeForCid } from '../services/ipfs.js'; import { getIndexedResearchObjects } from '../theGraph.js'; import { validateAndHealDataRefs, validateDataReferences } from '../utils/dataRefTools.js'; import { cleanupManifestUrl } from '../utils/manifest.js'; -import { hexToCid } from '../utils.js'; +import { ensureUuidEndsWithDot, hexToCid } from '../utils.js'; /* Usage Guidelines: @@ -18,6 +18,7 @@ Usage Guidelines: - START and END are optional flags, if set, it will only process nodes within the range. - MARK_EXTERNALS is an optional flag, if true, it will mark external refs as external, downside is that it can take significantly longer to process, also size diff checking disabled when marking externals. - TX_HASH is an optional param, used for fixing node version of a specific published node version. (Edgecase of multiple publishes with same manifestCid) +- COMMIT_ID is an optional param, used for fixing node version of a specific published node version. - USER_EMAIL is only required for the fillPublic operation - WORKING_TREE_URL is only required for the fillPublic operation, useful if a node is known to contain external cids, it can cut down the backfill time significantly for dags with external cids. @@ -38,7 +39,7 @@ healAll: OPERATION=healAll PUBLIC_REFS=true MARK_EXTERNALS=true npm run scr const logger = parentLogger.child({ module: 'SCRIPTS::dataRefDoctor' }); main(); -function main() { +async function main() { const { operation, nodeUuid, @@ -48,40 +49,42 @@ function main() { end, markExternals, txHash, + commitId, userEmail, workingTreeUrl, newNodeUuid, } = getOperationEnvs(); const startIterator = isNaN(start as any) ? undefined : parseInt(start); const endIterator = isNaN(end as any) ? undefined : parseInt(end); - switch (operation) { case 'validate': if (!nodeUuid && !manifestCid) return logger.error('Missing NODE_UUID or MANIFEST_CID'); - validateDataReferences({ nodeUuid, manifestCid, publicRefs, markExternals, txHash }); + await validateDataReferences({ nodeUuid, manifestCid, publicRefs, markExternals, txHash, commitId }); break; case 'heal': if (!nodeUuid && !manifestCid) return logger.error('Missing NODE_UUID or MANIFEST_CID'); - validateAndHealDataRefs({ nodeUuid, manifestCid, publicRefs, markExternals, txHash }); + await validateAndHealDataRefs({ nodeUuid, manifestCid, publicRefs, markExternals, txHash, commitId }); break; case 'validateAll': - dataRefDoctor(false, publicRefs, startIterator, endIterator, markExternals); + await dataRefDoctor(false, publicRefs, startIterator, endIterator, markExternals); break; case 'healAll': - dataRefDoctor(true, publicRefs, startIterator, endIterator, markExternals); + await dataRefDoctor(true, publicRefs, startIterator, endIterator, markExternals); break; case 'fillPublic': if (!nodeUuid && !userEmail) return logger.error('Missing NODE_UUID or USER_EMAIL'); - fillPublic(nodeUuid, userEmail, workingTreeUrl); + await fillPublic(nodeUuid, userEmail, workingTreeUrl); break; case 'clonePrivateNode': if (!nodeUuid && !newNodeUuid) return logger.error('Missing NODE_UUID or NEW_NODE_UUID'); - clonePrivateNode(nodeUuid, newNodeUuid); + await clonePrivateNode(nodeUuid, newNodeUuid); break; default: logger.error('Invalid operation, valid operations include: validate, heal, validateAll, healAll'); return; } + logger.info('DataRefDr has finished running'); + process.exit(0); } function getOperationEnvs() { @@ -95,6 +98,7 @@ function getOperationEnvs() { end: process.env.END, markExternals: process.env.MARK_EXTERNALS?.toLowerCase() === 'true' ? true : false, txHash: process.env.TX_HASH || null, + commitId: process.env.COMMIT_ID || null, workingTreeUrl: process.env.WORKING_TREE_URL || null, userEmail: process.env.USER_EMAIL || null, }; @@ -133,11 +137,14 @@ async function dataRefDoctor( `[DataRefDoctor]Processing node: ${nodes[i].id}, found versions indexed: ${totalVersionsIndexed}, for nodeUuid: ${node.uuid}`, ); for (let nodeVersIdx = 0; nodeVersIdx < totalVersionsIndexed; nodeVersIdx++) { - logger.info( - `[DataRefDoctor]Processing indexed version: ${nodeVersIdx}, with txHash: ${indexedNode.versions[nodeVersIdx]?.id}`, - ); const hexCid = indexedNode.versions[nodeVersIdx]?.cid || indexedNode.recentCid; const txHash = indexedNode.versions[nodeVersIdx]?.id; + const commitId = indexedNode.versions[nodeVersIdx]?.commitId; + const publishIdentifier = commitId || txHash; + + logger.info( + `[DataRefDoctor]Processing indexed version: ${nodeVersIdx}, with publishIdentifier: ${publishIdentifier}`, + ); const manifestCid = hexToCid(hexCid); if (heal) { await validateAndHealDataRefs({ @@ -146,9 +153,17 @@ async function dataRefDoctor( publicRefs: true, markExternals, txHash, + commitId, }); } else { - validateDataReferences({ nodeUuid: node.uuid, manifestCid, publicRefs: true, markExternals, txHash }); + validateDataReferences({ + nodeUuid: node.uuid, + manifestCid, + publicRefs: true, + markExternals, + txHash, + commitId, + }); } } } @@ -179,10 +194,15 @@ async function fillPublic(nodeUuid: string, userEmail: string, workingTreeUrl?: const user = await prisma.user.findUnique({ where: { email: userEmail } }); if (!user) return logger.error(`[FillPublic] Failed to find user with email: ${userEmail}`); - if (!nodeUuid.endsWith('.')) nodeUuid += '.'; + nodeUuid = ensureUuidEndsWithDot(nodeUuid); const { researchObjects } = await getIndexedResearchObjects([nodeUuid]); - if (!researchObjects.length) - logger.error(`[FillPublic] Failed to resolve any public nodes with the uuid: ${nodeUuid}`); + if (!researchObjects.length) { + logger.error( + { nodeUuid, researchObjects }, + `[FillPublic] Failed to resolve any published nodes with the uuid: ${nodeUuid}, aborting script`, + ); + return; + } const indexedNode = researchObjects[0]; const latestHexCid = indexedNode.recentCid; @@ -190,11 +210,13 @@ async function fillPublic(nodeUuid: string, userEmail: string, workingTreeUrl?: const manifestUrl = cleanupManifestUrl(latestManifestCid); const latestManifest = await (await axios.get(manifestUrl)).data; - if (!latestManifest) - return logger.error( + if (!latestManifest) { + logger.error( { manifestUrl, latestManifestCid }, - `[FillPublic] Failed to retrieve manifest from ipfs cid: ${latestManifestCid}`, + `[FillPublic] Failed to retrieve manifest from ipfs cid: ${latestManifestCid}, aborting script`, ); + return; + } const title = '[IMPORTED NODE]' + latestManifest.title || 'Imported Node'; let node = await prisma.node.findUnique({ where: { uuid: nodeUuid } }); @@ -214,18 +236,26 @@ async function fillPublic(nodeUuid: string, userEmail: string, workingTreeUrl?: const totalVersionsIndexed = indexedNode.versions.length || 0; try { for (let nodeVersIdx = 0; nodeVersIdx < totalVersionsIndexed; nodeVersIdx++) { - logger.info( - `[DataRefDoctor]Processing indexed version: ${nodeVersIdx}, with txHash: ${indexedNode.versions[nodeVersIdx]?.id}`, - ); const hexCid = indexedNode.versions[nodeVersIdx]?.cid || indexedNode.recentCid; const txHash = indexedNode.versions[nodeVersIdx]?.id; + const commitId = indexedNode.versions[nodeVersIdx]?.commitId; + const commitIdOrTxHash = commitId || txHash; + + logger.info( + `[DataRefDoctor]Processing indexed version: ${nodeVersIdx}, with ${commitId ? 'commitId:' : 'txHash'}: ${commitIdOrTxHash}`, + ); const manifestCid = hexToCid(hexCid); + const nodeVersionPublishIdentifiers = { + ...(txHash && { transactionId: txHash }), + ...(commitId && { commitId }), + }; + const nodeVersion = await prisma.nodeVersion.create({ data: { nodeId: node.id, manifestUrl: manifestCid, - transactionId: txHash, + ...nodeVersionPublishIdentifiers, }, }); @@ -242,7 +272,7 @@ async function fillPublic(nodeUuid: string, userEmail: string, workingTreeUrl?: }; logger.info( { manifestEntry }, - `[DataRefDoctor] Manifest entry being created for indexed version ${nodeVersIdx}, with txHash: ${indexedNode.versions[nodeVersIdx]?.id}`, + `[DataRefDoctor] Manifest entry being created for indexed version ${nodeVersIdx}, with publishIdentifier: ${commitIdOrTxHash}`, ); await prisma.publicDataReference.create({ data: manifestEntry }); @@ -252,10 +282,11 @@ async function fillPublic(nodeUuid: string, userEmail: string, workingTreeUrl?: manifestCid, publicRefs: true, txHash, + commitId, workingTreeUrl, }); logger.info( - `[DataRefDoctor]Successfully processed indexed node v: ${nodeVersIdx}, with txHash: ${indexedNode.versions[nodeVersIdx]?.id}, under user: ${user.email}`, + `[DataRefDoctor]Successfully processed indexed node v: ${nodeVersIdx}, with publishIdentifier: ${commitIdOrTxHash}, under user: ${user.email}`, ); } logger.info(`[FillPublic] Successfully backfilled data refs for public node: ${nodeUuid}`); @@ -272,7 +303,7 @@ async function fillPublic(nodeUuid: string, userEmail: string, workingTreeUrl?: totalVersionsIndexed, indexedNode, }, - `[FillPublic] Failed to backfill data refs for public node: ${nodeUuid}, error`, + `[FillPublic] Failed to backfill data refs for public node: ${nodeUuid}`, ); } } diff --git a/desci-server/src/utils/dataRefTools.ts b/desci-server/src/utils/dataRefTools.ts index cdd24429c..9998676f5 100644 --- a/desci-server/src/utils/dataRefTools.ts +++ b/desci-server/src/utils/dataRefTools.ts @@ -5,7 +5,7 @@ import axios from 'axios'; import { prisma } from '../client.js'; import { PUBLIC_IPFS_PATH } from '../config/index.js'; import { logger as parentLogger } from '../logger.js'; -import { discoveryLs, getDirectoryTree } from '../services/ipfs.js'; +import { discoveryLs, getDirectoryTree, getSizeForCid } from '../services/ipfs.js'; import { ensureUuidEndsWithDot, objectPropertyXor, omitKeys } from '../utils.js'; import { DRAFT_CID, TimestampMap, draftNodeTreeEntriesToFlatIpfsTree } from './draftTreeUtils.js'; @@ -81,6 +81,17 @@ export async function generateDataReferences({ ...(markExternals ? { external: null } : {}), }; + const manifestRefEntry: Prisma.PublicDataReferenceCreateManyInput = { + cid: manifestCid, + userId: node.ownerId, + root: false, + directory: false, + size: await getSizeForCid(manifestCid, false), + type: DataType.MANIFEST, + nodeId: node.id, + ...(versionId ? { versionId } : {}), + }; + const externalCidMap = workingTreeUrl ? await extractExternalCidMapFromTreeUrl(workingTreeUrl) : await generateExternalCidMap(node.uuid); @@ -117,7 +128,7 @@ export async function generateDataReferences({ }); // debugger; - return [...(isPublished ? [dataRootEntry] : []), ...dataTreeToPubRef]; + return [...(isPublished ? [dataRootEntry, manifestRefEntry] : [manifestRefEntry]), ...dataTreeToPubRef]; } // used to prepare data refs for a given dag and manifest (differs from generateDataReferences in that you don't need the updated manifestCid ahead of time) @@ -339,7 +350,7 @@ interface DiffObject { } // generateDataReferences() refs won't contain these keys, they will be omitted from the diff. -const DIFF_EXCLUSION_KEYS = ['id', 'createdAt', 'updatedAt', 'name', 'description']; +const DIFF_EXCLUSION_KEYS = ['id', 'createdAt', 'updatedAt', 'name', 'description', 'versionId']; export async function validateDataReferences({ nodeUuid, @@ -347,9 +358,11 @@ export async function validateDataReferences({ publicRefs, markExternals, txHash, + commitId, workingTreeUrl, }: ValidateAndHealDataRefsArgs) { if (nodeUuid.endsWith('.')) nodeUuid = nodeUuid.slice(0, -1); + // debugger; const node = await prisma.node.findFirst({ where: { uuid: ensureUuidEndsWithDot(nodeUuid), @@ -368,6 +381,7 @@ export async function validateDataReferences({ nodeId: node.id, manifestUrl: manifestCid, ...(txHash && { transactionId: txHash }), + ...(commitId && { commitId }), }, }) ).id @@ -375,9 +389,9 @@ export async function validateDataReferences({ const currentRefs = publicRefs ? await prisma.publicDataReference.findMany({ - where: { nodeId: node.id, type: { not: DataType.MANIFEST }, versionId }, + where: { nodeId: node.id, versionId }, }) - : await prisma.dataReference.findMany({ where: { nodeId: node.id, type: { not: DataType.MANIFEST } } }); + : await prisma.dataReference.findMany({ where: { nodeId: node.id } }); const requiredRefs = await generateDataReferences({ nodeUuid, @@ -488,7 +502,15 @@ export async function validateDataReferences({ ); logger.debug('_______________________________________________________________________________________'); } - return { missingRefs, unusedRefs, diffRefs }; + if (!totalMissingRefs && !totalUnusedRefs && !totalDiffRefs) + logger.info({ fn: 'validateDataReferences' }, `NodeId: ${node.id}, No missing, unused or diff refs found`); + return { + missingRefs, + unusedRefs, + diffRefs, + totalCurrentRefs: currentRefs.length, + totalRequiredRefs: requiredRefs.length, + }; } interface ValidateAndHealDataRefsArgs { @@ -497,6 +519,7 @@ interface ValidateAndHealDataRefsArgs { publicRefs: boolean; markExternals?: boolean; txHash?: string; + commitId?: string; workingTreeUrl?: string; } @@ -506,6 +529,7 @@ export async function validateAndHealDataRefs({ publicRefs, markExternals, txHash, + commitId, workingTreeUrl, }: ValidateAndHealDataRefsArgs) { const { missingRefs, unusedRefs, diffRefs } = await validateDataReferences({ @@ -514,6 +538,7 @@ export async function validateAndHealDataRefs({ publicRefs, markExternals, txHash, + commitId, workingTreeUrl, }); if (missingRefs.length) { From 238211720b75feb5a315579e05e5af2834759af9 Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:09:30 +0000 Subject: [PATCH 2/4] fix tests, optional include manifest in ref gen --- .../src/controllers/users/associateWallet.ts | 6 ++--- desci-server/src/scripts/dataRefDoctor.ts | 24 ++++++++++++------- desci-server/src/utils/dataRefTools.ts | 11 ++++++++- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/desci-server/src/controllers/users/associateWallet.ts b/desci-server/src/controllers/users/associateWallet.ts index d57cf0d7f..886783bb6 100755 --- a/desci-server/src/controllers/users/associateWallet.ts +++ b/desci-server/src/controllers/users/associateWallet.ts @@ -57,7 +57,7 @@ export const associateOrcidWallet = async (req: Request, res: Response, next: Ne if (hasOrcidWallet > 0) { res.status(202).send({ message: 'orcid DID already registered to this user' }); return; - }; + } // TODO: check for wallet uniqueness across all accounts const doesExist = @@ -69,7 +69,7 @@ export const associateOrcidWallet = async (req: Request, res: Response, next: Ne if (doesExist) { res.status(400).send({ err: 'orcid DID already register to some other' }); return; - }; + } try { const addWallet = await prisma.wallet.create({ @@ -312,7 +312,7 @@ const sendGiftTxn = async (user: User, walletAddress: string, addedWalletId: num */ const giftedWallets = await prisma.wallet.count({ where: { - user, + userId: user.id, giftTransaction: { not: null }, }, }); diff --git a/desci-server/src/scripts/dataRefDoctor.ts b/desci-server/src/scripts/dataRefDoctor.ts index e5617cb13..62bfa6f6b 100644 --- a/desci-server/src/scripts/dataRefDoctor.ts +++ b/desci-server/src/scripts/dataRefDoctor.ts @@ -66,10 +66,10 @@ async function main() { await validateAndHealDataRefs({ nodeUuid, manifestCid, publicRefs, markExternals, txHash, commitId }); break; case 'validateAll': - await dataRefDoctor(false, publicRefs, startIterator, endIterator, markExternals); + await dataRefDoctor({ heal: false, publicRefs, start: startIterator, end: endIterator, markExternals }); break; case 'healAll': - await dataRefDoctor(true, publicRefs, startIterator, endIterator, markExternals); + await dataRefDoctor({ heal: true, publicRefs, start: startIterator, end: endIterator, markExternals }); break; case 'fillPublic': if (!nodeUuid && !userEmail) return logger.error('Missing NODE_UUID or USER_EMAIL'); @@ -104,14 +104,16 @@ function getOperationEnvs() { }; } +type DataRefDoctorArgs = { + heal: boolean; + publicRefs: boolean; + start?: number; + end?: number; + markExternals?: boolean; +}; + //todo: add public handling -async function dataRefDoctor( - heal: boolean, - publicRefs: boolean, - start?: number, - end?: number, - markExternals?: boolean, -) { +async function dataRefDoctor({ heal, publicRefs, start, end, markExternals }: DataRefDoctorArgs) { const nodes = await prisma.node.findMany({ orderBy: { id: 'asc', @@ -154,6 +156,7 @@ async function dataRefDoctor( markExternals, txHash, commitId, + includeManifestRef: true, }); } else { validateDataReferences({ @@ -163,6 +166,7 @@ async function dataRefDoctor( markExternals, txHash, commitId, + includeManifestRef: true, }); } } @@ -174,6 +178,7 @@ async function dataRefDoctor( manifestCid: node.manifestUrl, publicRefs: false, markExternals, + includeManifestRef: true, }); } else { await validateDataReferences({ @@ -181,6 +186,7 @@ async function dataRefDoctor( manifestCid: node.manifestUrl, publicRefs: false, markExternals, + includeManifestRef: true, }); } } diff --git a/desci-server/src/utils/dataRefTools.ts b/desci-server/src/utils/dataRefTools.ts index 9998676f5..bc9a4de31 100644 --- a/desci-server/src/utils/dataRefTools.ts +++ b/desci-server/src/utils/dataRefTools.ts @@ -43,6 +43,7 @@ interface GenerateDataReferencesArgs { versionId?: number; markExternals?: boolean; workingTreeUrl?: string; + includeManifestRef?: boolean; } // generates data references for the contents of a manifest @@ -52,6 +53,7 @@ export async function generateDataReferences({ versionId, markExternals, workingTreeUrl, + includeManifestRef = false, }: GenerateDataReferencesArgs): Promise< Prisma.DataReferenceCreateManyInput[] | Prisma.PublicDataReferenceCreateManyInput[] > { @@ -128,7 +130,9 @@ export async function generateDataReferences({ }); // debugger; - return [...(isPublished ? [dataRootEntry, manifestRefEntry] : [manifestRefEntry]), ...dataTreeToPubRef]; + const manifestRefIncluded = includeManifestRef ? [manifestRefEntry] : []; + + return [...(isPublished ? [dataRootEntry, ...manifestRefIncluded] : [manifestRefEntry]), ...dataTreeToPubRef]; } // used to prepare data refs for a given dag and manifest (differs from generateDataReferences in that you don't need the updated manifestCid ahead of time) @@ -360,6 +364,7 @@ export async function validateDataReferences({ txHash, commitId, workingTreeUrl, + includeManifestRef = false, }: ValidateAndHealDataRefsArgs) { if (nodeUuid.endsWith('.')) nodeUuid = nodeUuid.slice(0, -1); // debugger; @@ -399,6 +404,7 @@ export async function validateDataReferences({ versionId, markExternals, workingTreeUrl, + includeManifestRef, }); const missingRefs = []; @@ -521,6 +527,7 @@ interface ValidateAndHealDataRefsArgs { txHash?: string; commitId?: string; workingTreeUrl?: string; + includeManifestRef?: boolean; } export async function validateAndHealDataRefs({ @@ -531,6 +538,7 @@ export async function validateAndHealDataRefs({ txHash, commitId, workingTreeUrl, + includeManifestRef = false, }: ValidateAndHealDataRefsArgs) { const { missingRefs, unusedRefs, diffRefs } = await validateDataReferences({ nodeUuid, @@ -540,6 +548,7 @@ export async function validateAndHealDataRefs({ txHash, commitId, workingTreeUrl, + includeManifestRef, }); if (missingRefs.length) { const addedRefs = publicRefs From a4997704a0823670e1ad05f15d64283f2a76a501 Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:28:46 +0000 Subject: [PATCH 3/4] fix test --- desci-server/src/utils/dataRefTools.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desci-server/src/utils/dataRefTools.ts b/desci-server/src/utils/dataRefTools.ts index bc9a4de31..82c82280f 100644 --- a/desci-server/src/utils/dataRefTools.ts +++ b/desci-server/src/utils/dataRefTools.ts @@ -132,7 +132,7 @@ export async function generateDataReferences({ const manifestRefIncluded = includeManifestRef ? [manifestRefEntry] : []; - return [...(isPublished ? [dataRootEntry, ...manifestRefIncluded] : [manifestRefEntry]), ...dataTreeToPubRef]; + return [...(isPublished ? [dataRootEntry, ...manifestRefIncluded] : [...manifestRefIncluded]), ...dataTreeToPubRef]; } // used to prepare data refs for a given dag and manifest (differs from generateDataReferences in that you don't need the updated manifestCid ahead of time) From 28fb07fb7c7e59642d909e8b5e8c3e72096890cf Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:57:15 +0000 Subject: [PATCH 4/4] proper fix tests --- desci-server/src/services/user.ts | 1 - desci-server/src/utils/dataRefTools.ts | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/desci-server/src/services/user.ts b/desci-server/src/services/user.ts index 28a039370..f333f44c9 100644 --- a/desci-server/src/services/user.ts +++ b/desci-server/src/services/user.ts @@ -153,7 +153,6 @@ export async function connectOrcidToUserIfPossible( logger.info({ fn: 'orcidCheck', user }, `Requesting user ${user}`); if (!user.orcid || user.orcid === orcid) { let nodeConnect: Awaited>; - debugger; if (!user.orcid || !(await isAuthTokenSetForUser(user.id))) { nodeConnect = await setOrcidForUser(user.id, orcid, { accessToken, diff --git a/desci-server/src/utils/dataRefTools.ts b/desci-server/src/utils/dataRefTools.ts index 82c82280f..ffed38cb4 100644 --- a/desci-server/src/utils/dataRefTools.ts +++ b/desci-server/src/utils/dataRefTools.ts @@ -392,11 +392,12 @@ export async function validateDataReferences({ ).id : undefined; + const excludeManifestClause = includeManifestRef ? {} : { type: { not: DataType.MANIFEST } }; const currentRefs = publicRefs ? await prisma.publicDataReference.findMany({ - where: { nodeId: node.id, versionId }, + where: { nodeId: node.id, versionId, ...excludeManifestClause }, }) - : await prisma.dataReference.findMany({ where: { nodeId: node.id } }); + : await prisma.dataReference.findMany({ where: { nodeId: node.id, ...excludeManifestClause } }); const requiredRefs = await generateDataReferences({ nodeUuid,