Skip to content

UN-2805 [FEAT] Add custom_data parameter for API deployment variable replacement overrides#202

Merged
jaseemjaskp merged 3 commits intomainfrom
UN-2805-add-user-data-paramter-for-api-deployment-for-variable-replacement-overrides
Sep 22, 2025
Merged

UN-2805 [FEAT] Add custom_data parameter for API deployment variable replacement overrides#202
jaseemjaskp merged 3 commits intomainfrom
UN-2805-add-user-data-paramter-for-api-deployment-for-variable-replacement-overrides

Conversation

@jagadeeswaran-zipstack
Copy link
Contributor

@jagadeeswaran-zipstack jagadeeswaran-zipstack commented Sep 22, 2025

What

  • Added CUSTOM_DATA constant to MetadataKey class for custom data handling
  • Updated BaseTool to extract and store custom_data from execution metadata with default empty dict
  • Version bump to v0.77.3

Why

  • API deployments need the ability to pass custom data for variable replacement overrides
  • This enables dynamic configuration and personalization of tool execution based on custom context
  • Provides a standardized way to handle custom data across the SDK
  • Name changed from user_data to custom_data for better consistency with existing naming conventions

How

  • Added CUSTOM_DATA constant to the MetadataKey enumeration in constants.py
  • Modified BaseTool.from_dict() to extract custom_data from execution metadata
  • Set default value as empty dict {} to maintain backward compatibility
  • Minor formatting improvement in error message for missing execution data

Can this PR break any existing features. If yes, please list possible items. If no, please explain why.

No, this PR should not break any existing features because:

  • The custom_data field is optional with a safe default value (empty dict)
  • Existing code that doesn't provide custom_data will continue to work unchanged
  • The change is purely additive - no existing functionality is modified or removed
  • All existing metadata handling remains the same

Env Config

  • No new environment variables required

Related Issues or PRs

Dependencies Versions / Env Variables

  • No dependency changes
  • No environment variable changes

Notes on Testing

  • Backward compatibility verified - existing tools will continue to work
  • Default empty dict ensures safe handling when custom_data is not provided
  • Testing should verify custom_data is properly extracted when present in execution metadata

Screenshots

N/A

Checklist

I have read and understood the Contribution Guidelines.

…nt overrides

- Added USER_DATA constant to MetadataKey class for user data handling
- Updated BaseTool to extract and store user_data from execution metadata
- Version bump to v0.77.2

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Renamed USER_DATA constant to CUSTOM_DATA in MetadataKey class
- Updated BaseTool to use custom_data instead of user_data
- Version bump to v0.77.3

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 22, 2025

Summary by CodeRabbit

  • New Features
    • Tools now receive execution custom data via a new custom_data field for easier runtime access.
  • Refactor
    • Replaced metadata key USER_DATA with CUSTOM_DATA; update integrations to use the new key.
  • Style
    • Minor formatting tweaks to certain error messages (no change to message content).
  • Chores
    • Bumped SDK version to v0.77.3.

Walkthrough

Bumps SDK version to v0.77.3. Adds MetadataKey.CUSTOM_DATA and updates BaseTool.from_tool_args to read metadata["custom_data"] (default {}) and assign it to tool.custom_data. Reformats a missing-file error message construction only.

Changes

Cohort / File(s) Summary of edits
Version bump
src/unstract/sdk/__init__.py
Updated module version constant from "v0.77.2" to "v0.77.3".
Metadata key update
src/unstract/sdk/constants.py
Replaced/added metadata constant: MetadataKey.CUSTOM_DATA = "custom_data" (removed USER_DATA).
Tool metadata handling
src/unstract/sdk/tool/base.py
from_tool_args now reads MetadataKey.CUSTOM_DATA from execution metadata (default {}) and assigns it to tool.custom_data. Reformatted missing-file error message construction without changing emitted message semantics.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Caller
    participant BaseTool as BaseTool.from_tool_args
    participant Metadata as Execution Metadata
    participant Tool as BaseTool instance

    Caller->>BaseTool: from_tool_args(args)
    BaseTool->>Metadata: load execution metadata (dict)
    Note right of Metadata #D3E4CD: metadata may include "custom_data"
    Metadata-->>BaseTool: metadata dict
    BaseTool->>Tool: tool.custom_data = metadata.get("custom_data", {})
    Note over BaseTool,Tool #F3E6FF: other init steps unchanged (args, files, etc.)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "UN-2805 [FEAT] Add custom_data parameter for API deployment variable replacement overrides" is specific and accurately reflects the primary change in the diff (adding CUSTOM_DATA/custom_data support and exposing it for API deployment overrides), includes the ticket reference and scope, and does not introduce unrelated or misleading information. It is somewhat long but remains clear for a teammate scanning history. Therefore it directly matches the main intent of the changeset.
Description Check ✅ Passed The PR description covers the core template sections ('What', 'Why', 'How', 'Related Issues or PRs', 'Dependencies Versions / Env Variables', 'Notes on Testing', 'Screenshots', and 'Checklist') with concrete content and explains the rationale and backward-compatibility considerations, so it is largely complete. The template's "Relevant Docs" section is missing and there is a minor inconsistency where the "How" section references BaseTool.from_dict() while the raw change summary indicates the change is applied in from_tool_args; please clarify the exact function modified. These are small fixes and do not prevent understanding the change, so the description passes but should be updated for completeness and accuracy.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch UN-2805-add-user-data-paramter-for-api-deployment-for-variable-replacement-overrides

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…yment-for-variable-replacement-overrides

Signed-off-by: jagadeeswaran-zipstack <jagadeeswaran@zipstack.com>
@jagadeeswaran-zipstack jagadeeswaran-zipstack changed the title Un 2805 add user data paramter for api deployment for variable replacement overrides UN-2805 [FEAT] Add custom_data parameter for API deployment variable replacement overrides Sep 22, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/unstract/sdk/constants.py (1)

138-138: Add brief doc for CUSTOM_DATA

Add a one-liner in MetadataKey’s docstring (and any public docs) to state intended shape and usage (e.g., overrides for variable replacement).

src/unstract/sdk/tool/base.py (2)

136-138: Include absolute path in missing-file error

Helps debugging by showing where we looked.

-            self.stream_error_and_exit(
-                f"{file_to_get} is missing in EXECUTION_DATA_DIR"
-            )
+            self.stream_error_and_exit(
+                f"{file_to_get} is missing in EXECUTION_DATA_DIR at {file_path}"
+            )

267-272: Avoid is for string comparison

is on strings is not reliable; use ==.

-        if output_type is PropKey.OutputType.JSON and not isinstance(data, dict):
+        if output_type == PropKey.OutputType.JSON and not isinstance(data, dict):
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to Reviews > Disable Cache setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 74ce83c and 0988d3a.

📒 Files selected for processing (3)
  • src/unstract/sdk/__init__.py (1 hunks)
  • src/unstract/sdk/constants.py (1 hunks)
  • src/unstract/sdk/tool/base.py (2 hunks)
🔇 Additional comments (1)
src/unstract/sdk/__init__.py (1)

1-1: Version bump to v0.77.3 — sync release artifacts

pyproject.toml is configured to read the version from src/unstract/sdk/init.py (dynamic = ['version']; [tool.hatch.version].path) — version in that file is "v0.77.3". Git tags and changelog/release-notes couldn't be verified here; confirm git tag v0.77.3 exists and that release notes/CHANGELOG reference v0.77.3, updating artifacts if missing.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/unstract/sdk/__init__.py (2)

3-5: LGTM; tiny optional hardening.

Optionally mark the constant as Final and export via all.

+from typing import Final
-__version__ = "v0.77.3"
+__version__: Final[str] = "v0.78.0"  # or the decided normalized value
+__all__ = ("__version__", "get_sdk_version")

1-1: Hatch will strip the leading "v" for packaging; consider making version PEP‑440 in-code.

pyproject.toml uses [tool.hatch.version] → src/unstract/sdk/init.py; Hatch's default regex accepts an optional leading "v" and normalizes versions per PEP 440 (built metadata will be "0.77.3"). (hatch.pypa.io)

version in src/unstract/sdk/init.py is currently "v0.77.3" — change to "0.77.3" if you want the runtime/in-code value to be PEP‑440 normalized.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to Reviews > Disable Cache setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 0988d3a and 08f43c3.

📒 Files selected for processing (2)
  • src/unstract/sdk/__init__.py (1 hunks)
  • src/unstract/sdk/constants.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/unstract/sdk/constants.py
🔇 Additional comments (1)
src/unstract/sdk/__init__.py (1)

1-1: Bump minor version (v0.78.0) or add back-compat for MetadataKey rename

Rename MetadataKey.USER_DATA → CUSTOM_DATA and BaseTool now reading metadata["custom_data"] is source‑breaking; a patch bump to v0.77.3 is misleading. Either:

  • Bump minor: apply
-__version__ = "v0.77.3"
+__version__ = "v0.78.0"
  • Or keep patch and add back‑compat:
    • alias USER_DATA → "custom_data" in constants (avoid @unique or duplicate-value Enum restriction).
    • In BaseTool.from_tool_args use metadata.get("custom_data") or metadata.get("user_data") or {} and emit a DeprecationWarning.

Repo search returned no matches for "user_data" or "custom_data"; unable to confirm blast radius — manually verify downstream integrations and published SDK dependents.

@jaseemjaskp jaseemjaskp merged commit 67971af into main Sep 22, 2025
2 checks passed
@jaseemjaskp jaseemjaskp deleted the UN-2805-add-user-data-paramter-for-api-deployment-for-variable-replacement-overrides branch September 22, 2025 13:06
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.

4 participants