Skip to content

Encode OpenAPI server variable values - #14146

Merged
Tao Chen (TaoChenOSU) merged 2 commits into
microsoft:mainfrom
eavanvalkenburg:fix-openapi-server-variable-encoding
Jul 9, 2026
Merged

Encode OpenAPI server variable values#14146
Tao Chen (TaoChenOSU) merged 2 commits into
microsoft:mainfrom
eavanvalkenburg:fix-openapi-server-variable-encoding

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Summary

  • validate enum-constrained OpenAPI server variables before substitution
  • percent-encode substituted server variable values, including defaults
  • add regression tests for invalid enum values and reserved-character encoding

Testing

  • uv run pytest tests/unit/connectors/openapi_plugin/test_sk_openapi.py -q

Validate enum-constrained server variables and percent-encode substituted values before constructing OpenAPI server URLs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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 hardens OpenAPI server URL construction for the Python OpenAPI plugin by validating enum-constrained server variables and percent-encoding substituted server variable values to prevent reserved characters from altering URL structure (e.g., host/path injection).

Changes:

  • Added enum validation for server variables when provided via arguments during server URL substitution.
  • Percent-encodes substituted server variable values (including defaults) during server URL construction.
  • Added regression tests covering enum validation (argument path) and reserved-character/default encoding.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py Adds enum validation for argument-provided server variables and percent-encodes substituted values in server URL templates.
python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py Adds unit tests for enum validation and percent-encoding behavior in get_server_url.

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

Comment thread python/semantic_kernel/connectors/openapi_plugin/models/rest_api_operation.py Outdated
Comment thread python/tests/unit/connectors/openapi_plugin/test_sk_openapi.py
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
connectors/openapi_plugin/models
   rest_api_operation.py2762790%101–102, 111–112, 121–122, 132, 141–142, 161–162, 171–172, 191–192, 228–229, 298, 306–309, 311, 355, 380, 382, 485
TOTAL28945565680% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4071 23 💤 0 ❌ 0 🔥 1m 49s ⏱️

Apply enum validation to default server-variable substitutions and cover the default fallback path with a regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 9, 2026
@TaoChenOSU
Tao Chen (TaoChenOSU) added this pull request to the merge queue Jul 9, 2026
Merged via the queue into microsoft:main with commit dd026f3 Jul 9, 2026
32 checks passed
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