Skip to content

fix no did logs#1383

Merged
giurgiur99 merged 1 commit into
mainfrom
fix/raw-algo-optional-1245
Jun 2, 2026
Merged

fix no did logs#1383
giurgiur99 merged 1 commit into
mainfrom
fix/raw-algo-optional-1245

Conversation

@giurgiur99
Copy link
Copy Markdown
Contributor

@giurgiur99 giurgiur99 commented Jun 1, 2026

Fixes #1245

Changes proposed in this PR:

@giurgiur99
Copy link
Copy Markdown
Contributor Author

/run-security-scan

Copy link
Copy Markdown
Member

@alexcos20 alexcos20 left a comment

Choose a reason for hiding this comment

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

AI automated code review (Gemini 3).

Overall risk: low

Summary:
The PR implements a clean and effective fix to allow raw-code algorithms to execute without attempting unnecessary DDO lookups. The architecture is maintained, performance is improved by bypassing unnecessary DB/network overhead, and test coverage correctly verifies both the returned state and the absence of side-effects.

Comments:
• [INFO][style] Good improvement using the falsy check (!elem.documentId) to catch empty strings, null, or undefined values that might bypass the in operator check and trigger failing lookups downstream.
• [INFO][performance] Excellent early return. Short-circuiting here when algoDID is falsy successfully avoids an unnecessary database/network hit via findAndFormatDdo and prevents logging noisy error messages. Good implementation.
• [INFO][other] Great unit test addition. Utilizing sinon to stub the DDO handler and spy on the logger accurately verifies that no unnecessary work or logging is occurring for raw-code algorithms. LGTM!

@giurgiur99 giurgiur99 marked this pull request as ready for review June 1, 2026 07:44
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 1, 2026

Greptile Summary

This PR fixes spurious error logs ("Algorithm with id: undefined not found!") that were emitted when raw-code algorithms—which have no DDO—were processed by getAlgoChecksums and the startCompute DDO-resolution loop.

  • utils.ts: getAlgoChecksums now accepts algoDID / algoServiceId as string | undefined and returns empty checksums immediately when algoDID is falsy, skipping the DDO lookup and its associated error log.
  • startCompute.ts: The per-element DDO-resolution loop now also skips elements whose documentId is present but falsy (|| !elem.documentId), complementing the existing key-presence guard.
  • compute.test.ts: A new unit test verifies that getAlgoChecksums(undefined, …) returns empty checksums, triggers no FindDdoHandler call, and emits no error log.

Confidence Score: 5/5

Straightforward guard additions that short-circuit two code paths for raw-code algorithms; no existing behavior changes for well-formed inputs.

Both changes add defensive guards in clearly isolated paths. The utils.ts early-return fires only when algoDID is falsy and returns the same empty-checksum struct that was already returned on DDO-not-found. The startCompute.ts change mirrors the guard that was already present for the key-absence case. Callers in initialize.ts and startCompute.ts already handle the empty-checksum return via the isRawCodeAlgorithm flag, so the new path is consistent with that logic. The accompanying test directly exercises the fixed path.

No files require special attention.

Important Files Changed

Filename Overview
src/components/core/compute/utils.ts Adds early-return guard for undefined algoDID; widens function signature to string
src/components/core/compute/startCompute.ts Adds falsy-documentId guard to the DDO-resolution loop, preventing lookups for elements where documentId exists as a key but is empty/undefined.
src/test/unit/compute.test.ts New unit test suite for getAlgoChecksums; correctly stubs FindDdoHandler and spies on CORE_LOGGER to assert no DDO lookup or error log occurs for undefined DID.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[startCompute: iterate algorithm + datasets] --> B{"'documentId' in elem\nAND elem.documentId?"}
    B -- No --> C[skip / continue]
    B -- Yes --> D[FindDdoHandler.findAndFormatDdo]
    D --> E{DDO found?}
    E -- No --> F[return 500 error]
    E -- Yes --> G[proceed with DDO validation]

    H[getAlgoChecksums called] --> I{algoDID defined?}
    I -- No --> J[return empty checksums\nno DDO lookup, no error log]
    I -- Yes --> K[FindDdoHandler.findAndFormatDdo]
    K --> L{DDO found?}
    L -- No --> M[log error, return empty checksums]
    L -- Yes --> N[compute file + container checksums]
Loading

Reviews (1): Last reviewed commit: "fix no did logs" | Re-trigger Greptile

@giurgiur99 giurgiur99 merged commit 59d927f into main Jun 2, 2026
25 of 27 checks passed
@giurgiur99 giurgiur99 deleted the fix/raw-algo-optional-1245 branch June 2, 2026 07:20
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.

C2D InitializeCompute: make algo fully optional

3 participants