Skip to content

Minor improvements - #32474

Merged
IceS2 merged 5 commits into
mainfrom
sec-code-scan
Sep 4, 2026
Merged

IceS2 merged 5 commits into
mainfrom
sec-code-scan

Conversation

@IceS2

@IceS2 IceS2 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Addresses a small set of ingestion code-scanning findings by clarifying intentional behavior, preventing configuration and exception details from being exposed, and migrating time utilities to zoneinfo. Adds focused regression coverage.

@IceS2
IceS2 requested a review from a team as a code owner September 2, 2026 12:12
Copilot AI lite review requested due to automatic review settings September 2, 2026 12:12
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Sep 2, 2026

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.

🟡 Changes recommended

The updated error handling can itself raise exceptions (e.g., HTTPStatus(exc.code) / non-int status comparisons), risking broken error responses at runtime.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR tightens ingestion- and managed-API error/log handling to avoid exposing sensitive internal details, updates time utilities to use zoneinfo, and adds regression tests to lock in the safer behavior.

Changes:

  • Sanitize server-side API error responses (generic 5xx payloads) and reduce detail leakage from exception handlers and validation responses.
  • Remove configured connector types from parser debug messages while retaining actionable parsing logs.
  • Migrate ingestion time utilities from pytz to zoneinfo, adding DST fold-related regression coverage.
File summaries
File Description
openmetadata-airflow-apis/tests/unit/test_response.py Adds regression tests ensuring 5xx responses don’t leak internal details while preserving safe 4xx messages.
openmetadata-airflow-apis/openmetadata_managed_apis/utils/parser.py Removes connector/type-specific details from inner-connection parsing messages; adjusts debug logging.
openmetadata-airflow-apis/openmetadata_managed_apis/operations/last_dag_logs.py Stops returning a detailed 500 message when log reading isn’t supported.
openmetadata-airflow-apis/openmetadata_managed_apis/operations/health.py Replaces detailed 400 error payload with a generic message.
openmetadata-airflow-apis/openmetadata_managed_apis/operations/deploy.py Removes server error payload that previously embedded exception details.
openmetadata-airflow-apis/openmetadata_managed_apis/api/routes/run_automation.py Replaces validation error detail with a generic client-facing message.
openmetadata-airflow-apis/openmetadata_managed_apis/api/routes/deploy.py Replaces validation error detail with a generic client-facing message.
openmetadata-airflow-apis/openmetadata_managed_apis/api/response.py Forces generic error text for 5xx responses and removes parameterized server_error.
openmetadata-airflow-apis/openmetadata_managed_apis/api/error_handlers.py Updates exception handlers to avoid returning exception repr/details.
ingestion/tests/unit/test_parser_logging.py Adds regression coverage ensuring debug logs don’t echo configured connector type text.
ingestion/tests/unit/metadata/utils/test_time_utils.py Adds parameterized tests for DST fold/nonexistent-time timestamp conversion behavior.
ingestion/src/metadata/utils/time_utils.py Migrates timezone handling to ZoneInfo and adjusts datetime→timestamp conversions.
ingestion/src/metadata/ingestion/source/dashboard/ssrs/client.py Adds justification and suppresses HTTP-mount security finding (adapter mount ≠ protocol selection).
ingestion/src/metadata/ingestion/ometa/http_adapter.py Adds justification and suppresses HTTP-mount security finding (adapter mount ≠ protocol selection).
ingestion/src/metadata/ingestion/api/parser.py Removes connector/type echoing from inner-connection parsing messages; updates debug logging style.
ingestion/src/metadata/core/connections/test_connection/checks/storage.py Documents and suppresses sonar finding around ExpectedBucketOwner for generic S3-compatible stores.
ingestion/src/metadata/cli/scaffold.py Documents and suppresses sonar finding about writing scaffolded files to validated paths.
Review details

Suppressed comments (1)

ingestion/src/metadata/utils/time_utils.py:54

  • Local variable tmsap looks like a typo and makes the logic harder to read/grep; since this function was modified, it’s a good opportunity to rename it to something clear (e.g., timestamp_seconds).
    if datetime_value.tzinfo is None:
        datetime_value = datetime_value.replace(tzinfo=tz)
    else:
        datetime_value = datetime_value.astimezone(tz)
    tmsap = datetime_value.timestamp()
    if milliseconds:
        return int(tmsap * 1000)
    return int(tmsap)
  • Files reviewed: 17/17 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 2, 2026 14:35
@IceS2 IceS2 added the skip-pr-checks Bypass PR metadata validation check label Sep 2, 2026

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.

🟡 Changes recommended

The new Flask unit tests build responses inside an app context but assert response.get_json() outside it, which can fail with “Working outside of application context” depending on Flask internals/version.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

openmetadata-airflow-apis/tests/unit/test_response.py:42

  • This test exits the Flask app_context before calling response.get_json(). That can fail on Flask versions where get_json relies on current_app.json. Keep the assertions inside the app_context to avoid context-related failures.
    with Flask(__name__).app_context():
        response = ApiResponse.bad_request(message)

    assert response.status_code == ApiResponse.STATUS_BAD_REQUEST
    assert response.get_json() == {"error": message}

openmetadata-airflow-apis/tests/unit/test_response.py:58

  • The assertions here run after the Flask app_context is closed. To avoid "Working outside of application context" errors when calling response.get_json(), keep the assertions inside the app_context.
    with Flask(__name__).app_context():
        response = ApiResponse.error(status, error)

    assert response.status_code == expected_status
    assert response.get_json() == {"error": expected_error}
  • Files reviewed: 18/18 changed files
  • Comments generated: 2
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 2, 2026 14:57
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 899df3c35085a59223e3924555631b4733503e26 in Playwright run 33761136833, attempt 1.

✅ 618 passed · ❌ 0 failed · 🟡 2 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 57m 40s

⏱️ Max setup 4m 17s · max shard execution 17m 47s · max shard-job elapsed before upload 21m 3s · reporting 5s

🌐 253.65 requests/attempt · 2.74 app boots/UI scenario · 11.06% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 253.65 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.74 per UI scenario (1784 boots / 652 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 147 0 0 0 0 0
✅ Shard chromium-02 130 0 0 0 0 0
✅ Shard chromium-03 122 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 25 0 0 0 0 0
🟡 Shard ingestion-02 37 0 2 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 2 flaky test(s) (passed on retry)
  • Features/DataQuality/DataQuality.spec.ts › Pagination functionality in test cases list (shard ingestion-02, 1 retry)
  • Features/TestSuitePipelineRedeploy.spec.ts › Re-deploy all test-suite ingestion pipelines (shard ingestion-02, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

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.

🟢 Approval recommended

The changes align with the stated security-hardening goals, include targeted regression tests, and I only found minor docstring consistency issues.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

ingestion/src/metadata/utils/time_utils.py:33

  • The docstring says “gap times remain nonexistent”, but datetime_to_timestamp always returns an integer timestamp (and the new tests assert a specific timestamp for a known DST-gap local time). This wording is misleading—nonexistent local times are being resolved to some offset per zoneinfo behavior.
    openmetadata-airflow-apis/openmetadata_managed_apis/utils/parser.py:64
  • Docstring param name is out of sync with the function signature: _parse_inner_connection takes connection_dict, but the docstring still documents config_dict, which makes the docs misleading.
  • Files reviewed: 18/18 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 3, 2026 13:26

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Addresses ingestion code-scanning findings by clarifying intentional behavior, preventing configuration and exception details from being exposed, and migrating time utilities to zoneinfo. HTTPStatus exception handling in the global error handler has been fixed, and regression coverage added.

✅ 1 resolved
✅ Edge Case: HTTPStatus(exc.code) can raise inside global error handler

📄 openmetadata-airflow-apis/openmetadata_managed_apis/api/error_handlers.py:30-31
In the app-wide exception handler, HTTPStatus(exc.code).phrase raises ValueError when exc.code is not a member of the HTTPStatus enum (non-standard codes) and raises when exc.code is None (the base HTTPException default). Because this is the global @app_errorhandler(Exception), a raise here escapes the handler and produces an unhandled 500, defeating its purpose. Werkzeug's HTTPException already carries the reason phrase in exc.name, which never raises — use that instead (e.g. ApiResponse.error(exc.code, exc.name)).

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Khairajani Khairajani 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.

LGTM

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'open-metadata-airflow-apis'

Failed conditions
0.0% Coverage on New Code (required ≥ 20%)

See analysis details on SonarQube Cloud

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

@IceS2
IceS2 added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit 6eefc35 Sep 4, 2026
115 of 116 checks passed
@IceS2
IceS2 deleted the sec-code-scan branch September 4, 2026 08:58
IceS2 added a commit that referenced this pull request Sep 7, 2026
IceS2 added a commit that referenced this pull request Sep 7, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants