refactor: reference platform constants instead of hardcoded strings#1747
Open
vldcmp-uipath wants to merge 1 commit into
Open
refactor: reference platform constants instead of hardcoded strings#1747vldcmp-uipath wants to merge 1 commit into
vldcmp-uipath wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors both uipath and uipath-platform to replace hardcoded environment variable names, header keys, and project file/folder names with shared constants from uipath.platform.common.constants, ensuring a single source of truth and eliminating mixed-case header duplication.
Changes:
- Replaced hardcoded env-var/header/file/folder string literals with
uipath.platform.common.constantsacross runtime, CLI, tracing, and eval code paths. - Canonicalized internal routing headers to the constant values (lowercase keys) and updated affected tests accordingly.
- Removed a duplicate
COMMUNITY_agents_SUFFIXdefinition and bumped package versions/lockfiles.
Reviewed changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/uipath/uv.lock | Updates lock metadata and bumps uipath / uipath-platform versions. |
| packages/uipath/tests/tracing/test_otel_exporters.py | Updates assertions to use platform header constants. |
| packages/uipath/tests/cli/chat/test_voice_bridge.py | Updates header assertions to use platform header constants. |
| packages/uipath/tests/cli/chat/test_bridge.py | Updates header assertions to use platform header constants. |
| packages/uipath/src/uipath/tracing/_otel_exporters.py | Replaces env var + header literals with platform constants for tracing exporter setup. |
| packages/uipath/src/uipath/functions/factory.py | Uses UIPATH_CONFIG_FILE constant as the default config filename. |
| packages/uipath/src/uipath/functions/init.py | Uses UIPATH_CONFIG_FILE constant when registering the default runtime factory. |
| packages/uipath/src/uipath/eval/mocks/_simulate_component_service.py | Uses platform internal header constants for routing headers. |
| packages/uipath/src/uipath/eval/evaluators/llm_as_judge_evaluator.py | Switches to platform COMMUNITY_agents_SUFFIX constant. |
| packages/uipath/src/uipath/eval/_helpers/evaluators_helpers.py | Removes duplicate COMMUNITY_agents_SUFFIX definition. |
| packages/uipath/src/uipath/_utils/_auth.py | Uses DOTENV_FILE constant for .env handling. |
| packages/uipath/src/uipath/_cli/models/uipath_json_schema.py | Uses UIPATH_CONFIG_FILE constant for default config loading. |
| packages/uipath/src/uipath/_cli/models/runtime_schema.py | Uses ENTRY_POINTS_FILE constant for $id default. |
| packages/uipath/src/uipath/_cli/cli_pack.py | Uses platform constants for common project filenames and related error messages. |
| packages/uipath/src/uipath/_cli/cli_new.py | Uses platform constants when generating project files and CLI messages. |
| packages/uipath/src/uipath/_cli/cli_invoke.py | Uses PYTHON_CONFIGURATION_FILE constant for reading project metadata. |
| packages/uipath/src/uipath/_cli/cli_init.py | Uses platform constants for config/env/entry-points/pyproject file handling. |
| packages/uipath/src/uipath/_cli/cli_eval.py | Uses ENV_FOLDER_KEY constant when setting env vars. |
| packages/uipath/src/uipath/_cli/_utils/_service_base.py | Uses platform env var constants when constructing a client from env. |
| packages/uipath/src/uipath/_cli/_utils/_project_files.py | Uses platform constants for project config discovery and eval folder handling. |
| packages/uipath/src/uipath/_cli/_utils/_common.py | Uses platform ENV_BASE_URL constant for CLI env validation. |
| packages/uipath/src/uipath/_cli/_telemetry.py | Uses ENV_UIPATH_AGENT_ID constant for telemetry enrichment. |
| packages/uipath/src/uipath/_cli/_push/sw_file_handler.py | Uses platform constants for ignored files and eval folder naming. |
| packages/uipath/src/uipath/_cli/_evals/_telemetry.py | Uses ENV_TENANT_ID constant for telemetry enrichment. |
| packages/uipath/src/uipath/_cli/_evals/_progress_reporter.py | Uses platform env var constants for project/agent identity and file-source attribution. |
| packages/uipath/src/uipath/_cli/_debug/_bridge.py | Uses platform env/header constants for remote debug bridge configuration. |
| packages/uipath/src/uipath/_cli/_chat/_voice_bridge.py | Uses platform env/header constants for conversational voice bridge headers. |
| packages/uipath/src/uipath/_cli/_chat/_bridge.py | Uses platform env/header constants for conversational chat bridge headers. |
| packages/uipath/src/uipath/_cli/_auth/_url_utils.py | Uses ENV_BASE_URL constant when resolving domain defaults. |
| packages/uipath/src/uipath/_cli/_auth/_auth_session.py | Uses ENV_UIPATH_ACCESS_TOKEN constant when persisting tokens to env. |
| packages/uipath/src/uipath/_cli/_auth/_auth_service.py | Uses platform env var constants when writing auth results to env and checking reuse. |
| packages/uipath/pyproject.toml | Bumps uipath version to 2.11.10. |
| packages/uipath-platform/uv.lock | Bumps uipath-platform version to 0.1.72 in lockfile. |
| packages/uipath-platform/tests/services/test_service_url_overrides.py | Updates header assertions to use platform header constants. |
| packages/uipath-platform/src/uipath/platform/common/_span_utils.py | Replaces tracing/process env var literals with constants. |
| packages/uipath-platform/src/uipath/platform/common/_service_url_overrides.py | Uses internal routing header constants when injecting routing headers. |
| packages/uipath-platform/src/uipath/platform/chat/_llm_gateway_service.py | Uses HEADER_AGENTHUB_CONFIG constant for optional header injection. |
| packages/uipath-platform/pyproject.toml | Bumps uipath-platform version to 0.1.72. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace hardcoded string literals (headers, env-var names, file names,
folder names, and the community-agents suffix) across the `uipath` and
`uipath-platform` packages with the constants defined in
`uipath.platform.common.constants` — the single source of truth.
Scope: source code only.
- Headers: X-UiPath-Internal-TenantId / -AccountId, x-uipath-folderkey,
x-uipath-agenthub-config now use HEADER_* constants.
- Env vars: UIPATH_URL, UIPATH_ACCESS_TOKEN, UIPATH_TENANT_ID,
UIPATH_ORGANIZATION_ID, UIPATH_FOLDER_KEY, UIPATH_JOB_KEY,
UIPATH_PROCESS_KEY/_UUID/_VERSION, UIPATH_TRACE_ID, UIPATH_PROJECT_ID,
UIPATH_AGENT_ID, UIPATH_PROJECT_FILES_SOURCE now use ENV_* constants.
- File names: pyproject.toml, uipath.json, entry-points.json,
bindings.json, studio_metadata.json, .env now use the *_FILE constants.
- Folder names: evals / evaluations now use LEGACY_EVAL_FOLDER /
EVALS_FOLDER.
- Removed a duplicate COMMUNITY_agents_SUFFIX definition in
evaluators_helpers.py and repointed its consumer to the platform constant.
Side-effect / bug fix: the header constants are lowercase
(e.g. "x-uipath-internal-tenantid") while several call sites set the
mixed-case literal ("X-UiPath-Internal-TenantId") as a plain-dict key.
When both spellings were present they were sent as two distinct headers
and merged server-side. Routing every call site through the single
constant collapses them to one canonical header, avoiding the duplicate.
Existing `uipath._utils.constants` and `uipath.eval.constants` imports are
left untouched (handled by the separate consolidation PR). A handful of
literals were intentionally not converted: user-facing message strings that
name a file/env-var in prose, and package paths that merely contain a
filename (e.g. "content/entry-points.json", "content/bindings_v2.json")
which have no exact matching constant.
Bumps uipath 2.11.9 -> 2.11.10 and uipath-platform 0.1.71 -> 0.1.72.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
be43eb0 to
9135a5e
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Replaces hardcoded string literals across the
uipathanduipath-platformpackages with the constants defined inuipath.platform.common.constants— the single source of truth. Source code only (tests untouched except where a key's casing changed; see below).Covers every constant in
platform/common/constants.pythat had hardcoded usages:X-UiPath-Internal-TenantId/-AccountId,x-uipath-folderkey,x-uipath-agenthub-config→HEADER_*UIPATH_URL,UIPATH_ACCESS_TOKEN,UIPATH_TENANT_ID,UIPATH_ORGANIZATION_ID,UIPATH_FOLDER_KEY,UIPATH_JOB_KEY,UIPATH_PROCESS_KEY/_UUID/_VERSION,UIPATH_TRACE_ID,UIPATH_PROJECT_ID,UIPATH_AGENT_ID,UIPATH_PROJECT_FILES_SOURCE→ENV_*pyproject.toml,uipath.json,entry-points.json,bindings.json,studio_metadata.json,.env→*_FILE/DOTENV_FILEevals/evaluations→LEGACY_EVAL_FOLDER/EVALS_FOLDERCOMMUNITY_agents_SUFFIXdefinition inevaluators_helpers.pyand repointed its consumer to the platform constant.Side-effect / bug fix
The header constants are lowercase (e.g.
x-uipath-internal-tenantid) while several call sites set the mixed-case literal (X-UiPath-Internal-TenantId) as a plain-dict key. When both spellings were present they were sent as two distinct headers and merged server-side. Routing every call site through the single constant collapses them to one canonical header, avoiding the duplicate.Notes / out of scope
uipath._utils.constantsanduipath.eval.constantsimports are left untouched — handled by the separate consolidation PR."content/entry-points.json","content/bindings_v2.json") which have no exact matching constant.cli_new,cli_invoke,functions/*,models/*, etc.) now import the platform package; this adds the platform import cost (~200–300ms) to those code paths, accepted in favor of single-source-of-truth consistency.Versions
uipath2.11.11 → 2.11.12uipath-platform0.1.74 → 0.1.75Testing
ruff check+ruff format --checkclean onsrcandtestsfor both packagesuipathanduipath-platform(only credential-gated integration tests skipped)uipath --helpworks🤖 Generated with Claude Code