Skip to content

fix: add-resource --to and --parent#475

Merged
qin-ctx merged 6 commits intovolcengine:mainfrom
MaojiaSheng:main
Mar 9, 2026
Merged

fix: add-resource --to and --parent#475
qin-ctx merged 6 commits intovolcengine:mainfrom
MaojiaSheng:main

Conversation

@MaojiaSheng
Copy link
Collaborator

Description

this PR solves #467

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ MaojiaSheng
❌ openviking


openviking seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@qin-ctx
Copy link
Collaborator

qin-ctx commented Mar 8, 2026

/review

@github-actions
Copy link

github-actions bot commented Mar 8, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

467 - Partially compliant

Compliant requirements:

  • Added --to and --parent flags in CLI (Rust code)
  • Updated API signatures across async/sync clients, local client, server router, and resource service
  • Added validation that only one of to/parent is set in multiple places
  • Implemented URI existence checks for --to (must not exist) and --parent (must exist and be directory) in TreeBuilder

Non-compliant requirements:

  • Missing reason parameter in abstract base client method
  • Broken argument order and missing reason in sync HTTP client call

Requires further human verification:

  • Verify backward compatibility for existing API users
  • Test error handling for edge cases (e.g., permission denied when checking URI existence)
  • Test CLI behavior with both --to and --parent flags
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

API Contract Break

Abstract add_resource method missing reason parameter, which is present in all implementations. This breaks the interface contract.

@abstractmethod
async def add_resource(
    self,
    path: str,
    to: Optional[str] = None,
    parent: Optional[str] = None,
    instruction: str = "",
    wait: bool = False,
    timeout: Optional[float] = None,
) -> Dict[str, Any]:
Critical Argument Bug

Sync HTTP client's add_resource call to async client is missing reason argument and has incorrect parameter order, leading to misaligned arguments.

return run_async(
    self._async_client.add_resource(
        path,
        to,
        parent,
        instruction,
        wait,
        timeout,
        strict,
Overly Broad Error Handling

URI existence checks catch all exceptions and either assume non-existence or re-raise as FileNotFoundError, masking other errors like permission issues.

if to_uri:
    # Exact target URI: must not exist yet
    try:
        await viking_fs.stat(to_uri, ctx=ctx)
        # If we get here, it already exists
        raise FileExistsError(f"Target URI already exists: {to_uri}")
    except FileExistsError:
        raise
    except Exception:
        # It doesn't exist, good to use
        pass
    candidate_uri = to_uri
else:
    if parent_uri:
        # Parent URI must exist and be a directory
        try:
            stat_result = await viking_fs.stat(parent_uri, ctx=ctx)
            if not stat_result.get("isDir"):
                raise ValueError(f"Parent URI is not a directory: {parent_uri}")
        except Exception as e:
            raise FileNotFoundError(f"Parent URI does not exist: {parent_uri}") from e

@MaojiaSheng
Copy link
Collaborator Author

I'll fix soon

@MaojiaSheng MaojiaSheng marked this pull request as draft March 9, 2026 08:47
@MaojiaSheng MaojiaSheng marked this pull request as ready for review March 9, 2026 08:59
@qin-ctx qin-ctx merged commit cb30ab7 into volcengine:main Mar 9, 2026
31 of 32 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants