fix(storage create-table --if-not-exists): report actual existing schema on skip (#349)#350
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #349 (the deferred follow-up filed before #348 merged).
storage create-table --if-not-existsreturnedaction: "skipped"with acolumns/primary_key/nameenvelope that re-echoed the caller'srequest 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 tableexists is now also the source of the returned schema:
columns/primary_key/name→ the existing table's actual valuesrequested_columns/requested_primary_key→ the caller's request, preservedschema_drift: bool→truewhen 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:linewhen
schema_driftis true. Theaction: "created"envelope is unchanged.Scope
--if-not-existsenvelope only.
create_tablereturns the service dict verbatim,so the new fields flow through
kbagent serveautomatically.0.47.0→0.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_drifttrue 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 existinground-trip to assert the skipped envelope reports actual columns + the
requested_*mirror, plus a divergent-request call assertingschema_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 entrysrc/keboola_agent_cli/commands/context.py— AGENT_CONTEXT noteplugins/kbagent/skills/kbagent/references/gotchas.md— caveat replaced withthe fixed-behavior note (
since v0.47.1)plugins/kbagent/skills/kbagent/references/commands-reference.mdplugin.json/marketplace.json/uv.lockviamake version-synckeboola-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 checkgreen (lint + format + skill + version + changelog + error-codes + 3617 tests)make typecheckclean (the singleunresolved-importwarning onscripts/hatch_build.pyis pre-existing, non-blocking)