Skip to content

fix: allow first push to a project with uninitialized file system#1820

Merged
cristipufu merged 1 commit into
mainfrom
fix/push-first-push-empty-project-404
Jul 17, 2026
Merged

fix: allow first push to a project with uninitialized file system#1820
cristipufu merged 1 commit into
mainfrom
fix/push-first-push-empty-project-404

Conversation

@cristipufu

Copy link
Copy Markdown
Member

Problem

uipath push fails on a freshly created Function project with:

❌ The targeted Studio Web project is not of type coded agent. Please check the UIPATH_PROJECT_ID environment variable.

or, depending on the backend response, an unhandled EnrichedException traceback (404).

The Studio Web backend returns 404 from FileOperations/Structure for projects whose file system was never initialized — even though the project exists (GET /Project/{id} returns 200 with projectType: "Function" and an empty rootFolder). Since push is exactly what would upload the first files, this is a bootstrap deadlock: the coded-agent validation (added in #937) blocks the very push that would initialize the project.

Verified against a live tenant: the FileOperations write path works fine on such a project; only Structure 404s until the first file exists. After the first push, Structure returns 200 with the full tree.

Fix

  • StudioClient.get_project_structure_async: treat a 404 from FileOperations/Structure as an empty project structure (first push bootstraps the files). Other HTTP errors propagate unchanged.
  • ensure_coded_agent_project_async: an empty remote structure (no files, no folders) is a never-pushed project — allow it instead of raising NonCodedAgentProjectException.

Testing

  • New test test_first_push_to_uninitialized_project: Structure returns 404 → push succeeds and uploads all files.
  • Existing tests unchanged: test_push_non_coded_agent_project (remote with files but no pyproject.toml still errors) and test_push_with_api_error (401 still propagates) keep passing.
  • tests/cli/test_push.py: 33 passed; tests/cli/test_pull.py: 12 passed; ruff + mypy clean.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 17, 2026 08:50
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-integrations labels Jul 17, 2026
The Studio Web backend returns 404 from FileOperations/Structure for
projects whose file system was never initialized (e.g. a freshly created
Function project), even though the project exists. This made the first
'uipath push' impossible: the coded-agent validation crashed with an
unhandled EnrichedException before any file could be uploaded.

Treat a 404 from the Structure endpoint as an empty project structure,
and let ensure_coded_agent_project_async accept an empty (never-pushed)
remote project so the first push can bootstrap the files. Other HTTP
errors still propagate unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cristipufu
cristipufu force-pushed the fix/push-first-push-empty-project-404 branch from 4ff596a to b82f3c4 Compare July 17, 2026 08:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bootstrap issue in the uipath push CLI flow when targeting a newly created Studio Web Function project whose remote file system is not yet initialized (backend returns 404 for FileOperations/Structure). It updates the Studio Web project validation/structure retrieval so the first push can succeed and initialize the remote tree.

Changes:

  • Treat FileOperations/Structure 404 as an empty remote structure in StudioClient.get_project_structure_async.
  • Allow coded-agent validation to pass when the remote structure is empty (interpreted as “never pushed yet”).
  • Add a CLI test covering first push to an uninitialized remote project (Structure 404 → push succeeds).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/uipath/src/uipath/_cli/_utils/_studio_project.py Treats remote Structure 404 as empty structure and relaxes coded-agent validation for empty projects.
packages/uipath/tests/cli/test_push.py Adds regression test ensuring first push succeeds when remote Structure initially returns 404.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +716 to +730
try:
response = await self.uipath.api_client.request_async(
"GET",
url=f"{self.file_operations_base_url}/Structure",
scoped="org",
)
structure = ProjectStructure.model_validate(response.json())
except EnrichedException as e:
# The backend returns 404 for projects whose file system was never
# initialized (e.g. a freshly created Function project): treat it
# as an empty structure so the first push can bootstrap the files.
if e.status_code != 404:
raise
structure = ProjectStructure(name="root", folders=[], files=[])

@andreitava-uip andreitava-uip left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be fine. I don't think we have any callers that explicitly handle 404s

@sonarqubecloud

Copy link
Copy Markdown

@cristipufu
cristipufu merged commit 487bf03 into main Jul 17, 2026
164 of 165 checks passed
@cristipufu
cristipufu deleted the fix/push-first-push-empty-project-404 branch July 17, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants