Skip to content

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

Merged
kirtimanmishrazipstack merged 1 commit intomainfrom
UN-2805-add-user-data-paramter-for-api-deployment-for-variable-replacement-overrides
Sep 19, 2025
Merged

UN-2805 [FEAT] Add custom_data parameter for API deployment variable replacement overrides#201
kirtimanmishrazipstack merged 1 commit 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 19, 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>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 19, 2025

Summary by CodeRabbit

  • New Features
    • Tools can now access user-specific metadata via a dedicated user_data field (defaults to empty when not provided).
    • Introduces a new metadata key to store user data for broader extensibility.
  • Chores
    • Bumped SDK version to v0.77.2.

Walkthrough

Updates SDK version to v0.77.2, introduces a new metadata key USER_DATA, and extends BaseTool to expose a user_data attribute populated from tool metadata (defaulting to an empty dict). Minor non-functional formatting change in an error raise within BaseTool.

Changes

Cohort / File(s) Summary
Version bump
src/unstract/sdk/__init__.py
Updated public constant __version__ from "v0.77.1" to "v0.77.2".
User data plumbing
src/unstract/sdk/constants.py, src/unstract/sdk/tool/base.py
Added MetadataKey.USER_DATA = "user_data". Added BaseTool.user_data (dict) set via from_tool_args from METADATA.USER_DATA, default {}. Reformatted _get_file_from_data_dir error raise without changing behavior.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant BaseTool
  participant ToolArgs as ToolArgs (includes METADATA)
  rect rgba(200,235,255,0.3)
    note over Caller,BaseTool: Tool construction via from_tool_args
    Caller->>BaseTool: from_tool_args(tool_args)
    BaseTool->>ToolArgs: Read METADATA["user_data"]
    alt user_data present
      BaseTool->>BaseTool: Set instance.user_data = value
    else user_data absent
      BaseTool->>BaseTool: Set instance.user_data = {}
      note right of BaseTool: Default path
    end
    BaseTool-->>Caller: Return initialized instance
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description includes the repository template headings but is filled with placeholders ('...' or '-') rather than substantive content, so required information is missing or incomplete. Key sections such as What, Why, How, Notes on Testing, and Dependencies/Env details provide no actionable context for reviewers. Because the description lacks necessary details for review, this check fails. Please replace placeholders with concrete details: clearly state what changed (for example, addition of MetadataKey.USER_DATA and BaseTool.user_data), why the change is required (reference UN-2805), and how it was implemented. Add Notes on Testing with steps and expected outcomes, list any dependency or environment variable impacts, link relevant docs or related issues/PRs, and confirm the checklist so reviewers can validate the change.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title 'UN-2805 Add user_data parameter for API deployment variable replaceme…' directly describes the primary change (adding a user_data parameter) and aligns with the modifications to MetadataKey and BaseTool in the changeset, making it concise and focused. It includes the relevant ticket reference for traceability. The trailing ellipsis suggests truncation but does not obscure the intent.
✨ 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

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

@jagadeeswaran-zipstack jagadeeswaran-zipstack changed the title UN-2805 Add user_data parameter for API deployment variable replaceme… UN-2805 [FEAT] Add user_data parameter for API deployment variable replacement overrides Sep 19, 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/unstract/sdk/tool/base.py (1)

266-273: Use equality (==) instead of identity (is) for string comparison.

is on strings is unreliable; use == to avoid intermittent misclassification of output type.

-        if output_type is PropKey.OutputType.JSON and not isinstance(data, dict):
+        if output_type == PropKey.OutputType.JSON and not isinstance(data, dict):
🧹 Nitpick comments (1)
src/unstract/sdk/constants.py (1)

138-138: Add brief comment and clarify allowable content for USER_DATA.

To avoid accidental PII persistence in METADATA.json, document expected schema and constraints.

-    USER_DATA = "user_data"
+    # Arbitrary per-user overrides for variable replacement; must be JSON-serializable,
+    # minimal, and free of sensitive/PII. This metadata is persisted in METADATA.json.
+    USER_DATA = "user_data"
📜 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 4afc1f2 and 46e91df.

📒 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 (2)
src/unstract/sdk/tool/base.py (1)

136-138: Error formatting change is fine.

No behavior change; message remains clear and actionable.

src/unstract/sdk/__init__.py (1)

1-1: Version bump LGTM — confirm tag & changelog

  • src/unstract/sdk/init.py: version = "v0.77.2".
  • Root pyproject.toml uses dynamic = ["version"] (hatch); many adapter subpackage pyproject.toml files still show version = "0.0.1".
  • Confirm a release tag "v0.77.2" exists and CHANGELOG/release notes are updated, and verify hatch/git-derived package version matches the bumped value (check whether the leading "v" is intentional/PEP 440–compatible).

Copy link
Contributor

@harini-venkataraman harini-venkataraman left a comment

Choose a reason for hiding this comment

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

LGTM

@kirtimanmishrazipstack kirtimanmishrazipstack merged commit 74ce83c into main Sep 19, 2025
2 checks passed
@kirtimanmishrazipstack kirtimanmishrazipstack deleted the UN-2805-add-user-data-paramter-for-api-deployment-for-variable-replacement-overrides branch September 19, 2025 08:01
@jagadeeswaran-zipstack jagadeeswaran-zipstack changed the title UN-2805 [FEAT] Add user_data parameter for API deployment variable replacement overrides UN-2805 [FEAT] Add custom_data parameter for API deployment variable replacement overrides Sep 22, 2025
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.

5 participants