Skip to content

fix: When the AGFS backend is s3, the error "pyagfs.exceptions.AGFSClientError: parent directory does not exist" occurs.#254

Merged
MaojiaSheng merged 1 commit intovolcengine:mainfrom
baojun-zhang:fix-directory-create-error
Feb 22, 2026
Merged

fix: When the AGFS backend is s3, the error "pyagfs.exceptions.AGFSClientError: parent directory does not exist" occurs.#254
MaojiaSheng merged 1 commit intovolcengine:mainfrom
baojun-zhang:fix-directory-create-error

Conversation

@baojun-zhang
Copy link
Collaborator

@baojun-zhang baojun-zhang commented Feb 22, 2026

fix: When the AGFS backend is s3, the error "pyagfs.exceptions.AGFSClientError: parent directory does not exist" occurs.

Description

In the commit Refactor S3 configuration , VikingFS.mkdir did not perform AGFS's mkdir operation on the target directory (see lines 141–153 of the current repository viking_fs.py, where only the parent directories are guaranteed by _ensure_parent_dirs), so it did not trigger s3fs's "parent directory must exist" check. However, in the latest version of the code you are currently using, VikingFS.mkdir is changed to directly call self.agfs.mkdir(path), causing s3fs to return "parent directory does not exist" when the parent directory does not exist.

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • First, check for explicit directory tag files (using HeadObject).

  • If a directory tag file exists, return True directly.

  • If it doesn't exist, use ListObjectsV2 to check if an object starting with that prefix exists.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Additional Notes

error stack:

2026-02-22 22:25:21,070 - openviking.parse.parsers.markdown - ERROR - [MarkdownParser] Parse failed: parent directory does not exist: temp/02222225_5d4083
Traceback (most recent call last):
File "./.venv/lib/python3.11/site-packages/pyagfs/client.py", line 260, in mkdir
response.raise_for_status()
File "./.venv/lib/python3.11/site-packages/requests/models.py", line 1026, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:8080/api/v1/directories?path=%2Flocal%2Ftemp%2F02222225_5d4083%2Ftmp2uppf5pw&mode=755

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./openviking/parse/parsers/markdown.py", line 190, in parse_content
await self._parse_and_create_structure(content, headings, root_dir, source_path)
File "./openviking/parse/parsers/markdown.py", line 386, in _parse_and_create_structure
await viking_fs.mkdir(root_dir)
File "./openviking/storage/viking_fs.py", line 158, in mkdir
self.agfs.mkdir(path)
File "./.venv/lib/python3.11/site-packages/pyagfs/client.py", line 263, in mkdir
self._handle_request_error(e)
File "./.venv/lib/python3.11/site-packages/pyagfs/client.py", line 54, in _handle_request_error
raise AGFSClientError(error_msg)
pyagfs.exceptions.AGFSClientError: parent directory does not exist: temp/02222225_5d4083
Error: 'root_uri'

fix

(.venv) OpenViking % openviking add-resource https://github.com/volcengine/OpenViking/blob/main/README_CN.md
status errors source_path meta root_uri
success [] /var/folders/52/2t1rc00n17x83f71n73_3zzh0000gn/T/tmplhvb_7wa.md {'url': 'https://github.com/volcengine/OpenViking/blob/main/README_CN.md', 'detected_by': 'extension', 'extension': '.md', 'downloaded_from': 'https://github.com/volcengine/OpenViking/blob/main/README_CN.md', 'url_type': 'download_markdown'} viking://resources/tmplhvb_7wa
(.venv) OpenViking % openviking

…ientError: parent directory does not exist" occurs.
@MaojiaSheng MaojiaSheng merged commit 66fdea2 into volcengine:main Feb 22, 2026
21 of 22 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Feb 22, 2026
@baojun-zhang baojun-zhang deleted the fix-directory-create-error branch February 27, 2026 03:32
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.

2 participants