Skip to content

fix(storage create-table --if-not-exists): report actual existing schema on skip (#349)#350

Merged
padak merged 1 commit into
mainfrom
fix/if-not-exists-actual-schema
May 27, 2026
Merged

fix(storage create-table --if-not-exists): report actual existing schema on skip (#349)#350
padak merged 1 commit into
mainfrom
fix/if-not-exists-actual-schema

Conversation

@padak
Copy link
Copy Markdown
Member

@padak padak commented May 26, 2026

Summary

Closes #349 (the deferred follow-up filed before #348 merged).

storage create-table --if-not-exists returned action: "skipped" with a
columns / primary_key / name envelope that re-echoed the caller's
request
instead of reporting the existing table's real schema. A caller
probing the skipped envelope to discover the actual shape of a pre-existing
table got the wrong values whenever the existing table differed from what was
requested.

The get_table_detail(target_id) lookup that already runs to confirm the table
exists is now also the source of the returned schema:

  • columns / primary_key / name → the existing table's actual values
  • requested_columns / requested_primary_key → the caller's request, preserved
  • schema_drift: booltrue when the existing table diverges from the request
    (set comparison, so column/PK reordering is not a false positive)

Human-mode output prints the actual schema on a skip and emits a Warning: line
when schema_drift is true. The action: "created" envelope is unchanged.

Scope

  • No new flag, no signature change — refines the existing --if-not-exists
    envelope only.
  • HTTP router needs no change: create_table returns the service dict verbatim,
    so the new fields flow through kbagent serve automatically.
  • Bumps 0.47.00.47.1 (behavior change to a shipped envelope).

Envelope (skipped)

{
  "table_id": "in.c-foo.bar",
  "name": "bar",
  "columns": ["id", "name"],
  "primary_key": ["id"],
  "requested_columns": ["id", "name", "extra"],
  "requested_primary_key": ["extra"],
  "schema_drift": true,
  "action": "skipped",
  "skip_reason": "table already exists"
}

Tests

  • tests/test_storage_write.py — skipped returns actual schema (not request);
    schema_drift true on divergence, false on match; order-insensitive drift;
    human-mode warning + actual-schema render.
  • tests/test_e2e.py::TestE2E_0_47_0_NewSurfaces — extended the existing
    round-trip to assert the skipped envelope reports actual columns + the
    requested_* mirror, plus a divergent-request call asserting schema_drift: true.

Plugin sync-map

Behavior change (not a new command), so the touched surfaces are:

  • src/keboola_agent_cli/changelog.py — 0.47.1 entry
  • src/keboola_agent_cli/commands/context.py — AGENT_CONTEXT note
  • plugins/kbagent/skills/kbagent/references/gotchas.md — caveat replaced with
    the fixed-behavior note (since v0.47.1)
  • plugins/kbagent/skills/kbagent/references/commands-reference.md
  • plugin.json / marketplace.json / uv.lock via make version-sync

keboola-expert.md §3 not touched: the fix makes the envelope more trustworthy
(actual schema), introducing no new wrong-by-default behavior — the detailed note
lives in gotchas.md.

Checks

  • make check green (lint + format + skill + version + changelog + error-codes + 3617 tests)
  • make typecheck clean (the single unresolved-import warning on scripts/hatch_build.py is pre-existing, non-blocking)

Open in Devin Review

…ema on skip (#349)

The action:"skipped" envelope now returns the EXISTING table's columns /
primary_key / name (sourced from the get_table_detail probe that confirms
the table exists) instead of re-echoing the caller's request. The requested
values are preserved under requested_columns / requested_primary_key, and a
new schema_drift flag marks when the existing table diverges from the request.
Human-mode output shows the actual schema on a skip and warns on drift.

Bumps 0.47.0 -> 0.47.1.
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@padak padak merged commit 2f80aaa into main May 27, 2026
3 checks passed
@padak padak deleted the fix/if-not-exists-actual-schema branch May 27, 2026 06:35
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.

storage create-table --if-not-exists: skipped envelope returns requested schema, not actual existing table schema

1 participant