Skip to content

Conversation

@tangledbytes
Copy link
Member

@tangledbytes tangledbytes commented Sep 1, 2025

Describe the Problem

Previous regex was pretty rigid in what kind of task id it can accept which is not correct. Task ID can be of the following types:

  • task ID is tmp15nwx2vl:1000:1002
  • task ID is 1000:1002:1003:1004:1005:1006
  • task ID is 1000
  • task ID is tmp15nwx2vl
  • task ID is tmp15nwx2vl_123:tmpn9km_wyx:1001

Explain the Changes

PR changes the regex to task ID is ([\w]+(:[\w]+)*) (as suggested my Sasaki-san).

Issues: Fixed #xxx / Gap #xxx

  1. https://github.ibm.com/Tier2/Test-Issue/issues/150

Testing Instructions:

  • Doc added/updated
  • Tests added

Summary by CodeRabbit

  • Bug Fixes

    • Improved task ID detection in TapeCloud operations to more reliably extract compound IDs (including colon‑separated segments) and to preserve the original error when the ID format is unexpected.
  • Documentation

    • Cleaned up parameter annotations for Glacier-related methods to improve readability and consistency in generated docs.

@coderabbitai
Copy link

coderabbitai bot commented Sep 1, 2025

Walkthrough

Single-file change in src/sdk/glacier_tapecloud.js: tapecloud_failure_handler now uses a single regex (/task ID is ([\w]+(:[\w]+)*)/) and reads the captured ID from match[1]; if no match, the original error is rethrown. Minor JSDoc whitespace edits; no signature changes.

Changes

Cohort / File(s) Summary
Failure handler parsing
src/sdk/glacier_tapecloud.js
Replaced two-step/fallback task-ID extraction with a single regex match (/task ID is ([\w]+(:[\w]+)*)/), using match[1] for the captured ID; if no match, the original error is thrown.
JSDoc formatting
src/sdk/glacier_tapecloud.js
Removed trailing spaces after type annotations in JSDoc for stage_migrate, migrate, stage_restore, and restore. No signature or behavior changes.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant TapeCloudUtils
    Caller->>TapeCloudUtils: call tapecloud_failure_handler(error, stdout)
    alt stdout matches /task ID is .../
        TapeCloudUtils->>TapeCloudUtils: match = stdout.match(/task ID is ([\w]+(:[\w]+)*)/)
        TapeCloudUtils->>TapeCloudUtils: taskId = match[1]
        TapeCloudUtils->>Caller: throw enriched error including taskId
    else no match
        TapeCloudUtils->>Caller: rethrow original error
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "[GLACIER] Fix task ID regex" concisely and accurately summarizes the primary change: updating the regex that parses Glacier task IDs. It includes the subsystem context (GLACIER) and the nature of the change (fix/regex) so a reviewer scanning history will understand the main intent. This aligns with the PR description and the change in tapecloud_failure_handler to accept broader task ID formats.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b14a1e3 and 667baeb.

📒 Files selected for processing (1)
  • src/sdk/glacier_tapecloud.js (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/sdk/glacier_tapecloud.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-package-lock-validation
  • GitHub Check: run-jest-unit-tests

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/sdk/glacier_tapecloud.js (1)

195-197: JSDoc whitespace tidy-up looks good

Docblocks read cleaner; no API surface change. Thanks for keeping these consistent.

Also applies to: 265-266, 311-312, 375-376

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e7905e7 and 467d36c.

📒 Files selected for processing (1)
  • src/sdk/glacier_tapecloud.js (5 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-18T05:00:21.149Z
Learnt from: tangledbytes
PR: noobaa/noobaa-core#9183
File: src/sdk/glacier_tapecloud.js:273-311
Timestamp: 2025-08-18T05:00:21.149Z
Learning: In TapeCloudGlacier.migrate method, ignoring the boolean return value from _migrate() and always proceeding to unstage entries is acceptable behavior - the migrate operation doesn't require checking the return value like other operations might.

Applied to files:

  • src/sdk/glacier_tapecloud.js
📚 Learning: 2025-08-18T05:00:52.294Z
Learnt from: tangledbytes
PR: noobaa/noobaa-core#9183
File: src/sdk/glacier_tapecloud.js:377-406
Timestamp: 2025-08-18T05:00:52.294Z
Learning: In TapeCloudGlacier.restore method, the method always returns true (rather than propagating _recall() result) because it uses a staging approach where the original log file should always be deleted after processing. Failed entries are captured by failure_recorder for retry through staged files, so the original log preservation is not needed.

Applied to files:

  • src/sdk/glacier_tapecloud.js
📚 Learning: 2025-08-05T10:05:51.959Z
Learnt from: tangledbytes
PR: noobaa/noobaa-core#9183
File: src/sdk/glacier_tapecloud.js:507-509
Timestamp: 2025-08-05T10:05:51.959Z
Learning: In TapeCloudGlacier._finalize_restore method, when failure_recorder is not provided but the DMAPI premig check fails, the code intentionally throws an error to cause the entire batch to fail and preserve the log file for retry, preventing files from being silently stuck in an unrestored state.

Applied to files:

  • src/sdk/glacier_tapecloud.js
🧬 Code graph analysis (1)
src/sdk/glacier_tapecloud.js (1)
src/endpoint/s3/s3_utils.js (1)
  • match (152-152)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-jest-unit-tests
  • GitHub Check: run-package-lock-validation

Comment on lines +123 to 126
const match = stdout.match(/task ID is ([\w]+(:[\w]+)*)/);
if (!match || match.length < 2) {
throw error;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard against missing stdout and anchor the regex to a line

Avoid a TypeError when error.stdout is absent, and reduce false positives by matching a whole line (multiline). Also, since we now accept word chars and colons, the nearby comment implying numeric-only segments is misleading—consider updating it.

Apply:

-        const match = stdout.match(/task ID is ([\w]+(:[\w]+)*)/);
-        if (!match || match.length < 2) {
-            throw error;
-        }
+        const stdoutStr = typeof stdout === 'string' ? stdout : '';
+        const match = stdoutStr.match(/^\s*task ID is ([\w]+(?:[:][\w]+)*)\s*$/m);
+        if (!match) {
+            throw error;
+        }

Optional (if hyphens or dots can appear in task IDs), broaden the charset to [\w.-]+ and add a test. Happy to update if confirmed.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const match = stdout.match(/task ID is ([\w]+(:[\w]+)*)/);
if (!match || match.length < 2) {
throw error;
}
const stdoutStr = typeof stdout === 'string' ? stdout : '';
const match = stdoutStr.match(/^\s*task ID is ([\w]+(?:[:][\w]+)*)\s*$/m);
if (!match) {
throw error;
}

Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com>
@tangledbytes tangledbytes merged commit ba9e8d8 into noobaa:master Sep 15, 2025
18 of 19 checks passed
nimrod-becker added a commit that referenced this pull request Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants