Skip to content

fix: reload runtime factory after login#95

Merged
cristipufu merged 1 commit intomainfrom
fix/reload-factory-after-login
Mar 2, 2026
Merged

fix: reload runtime factory after login#95
cristipufu merged 1 commit intomainfrom
fix/reload-factory-after-login

Conversation

@cristipufu
Copy link
Member

Summary

  • The UiPath runtime caches credentials at init time (UiPathApiConfig). When the server starts unauthenticated and the user logs in, os.environ gets updated but the factory still holds stale credentials → 401s on evals/runs
  • After successful login, _finalize_tenant now triggers server.reload_factory() via an _on_authenticated callback, so the runtime is recreated with fresh credentials
  • Write .env using the same approach as uipath auth CLI (update_env_file pattern)
  • load_dotenv now uses explicit dotenv_path=cwd/.env + override=True, matching the CLI root
  • Bump version to 0.0.69

Test plan

  • Start dev server without credentials → try running evals (expect 401)
  • Login via UI → run evals again (should succeed without server restart)
  • Verify .env contains UIPATH_ACCESS_TOKEN, UIPATH_URL, UIPATH_TENANT_ID, UIPATH_ORGANIZATION_ID

🤖 Generated with Claude Code

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

@cristipufu cristipufu force-pushed the fix/reload-factory-after-login branch from e19cad8 to bed2b16 Compare March 2, 2026 06:38
The UiPath runtime caches credentials at init time via UiPathApiConfig.
When the server starts unauthenticated and the user logs in later,
os.environ gets updated but the existing factory still holds stale
(empty) credentials, causing 401s on subsequent API calls.

- Add _on_authenticated callback to AuthState, wired in create_app to
  trigger server.reload_factory() after successful login
- Use _update_env_file (mirrors uipath._utils._auth.update_env_file)
  to write .env the same way as `uipath auth`
- Use load_dotenv(dotenv_path=cwd/.env, override=True) matching the
  CLI root behavior
- Bump version to 0.0.69

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cristipufu cristipufu force-pushed the fix/reload-factory-after-login branch from bed2b16 to 7a76bba Compare March 2, 2026 06:45
@cristipufu cristipufu merged commit b1812f9 into main Mar 2, 2026
11 checks passed
@cristipufu cristipufu deleted the fix/reload-factory-after-login branch March 2, 2026 06:47
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.

2 participants