Skip to content

fix(json): only flag strict ISO dates, not 10-char dashed strings (#1416)#1530

Open
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/issue-1416
Open

fix(json): only flag strict ISO dates, not 10-char dashed strings (#1416)#1530
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/issue-1416

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

Problem (#1416)

rtk aws eks list-clusters (and any AWS list-* op handled by the generic JSON schema path) rendered cluster names like `my-cluster` as `date?` instead of a string. EKS cluster names of length 10 that contain a `-` (very common!) hit the placeholder.

Root cause

`src/cmds/system/json_cmd.rs` extracts a schema for JSON values. The string-classification heuristic treated any string of length 10 containing `-` as a probable date:

```rust
} else if s.contains('-') && s.len() == 10 {
format!("{}date?", indent)
```

That collides with EKS cluster names, slugs, and many short identifiers (`abcd-12-xy`, `foo-bar-ab`, `my-cluster`, …).

Fix

Tightened the heuristic to a strict `^\d{4}-\d{2}-\d{2}$` regex, compiled once via `lazy_static`. Real ISO calendar dates are still classified as `date?`; everything else falls back to `string`.

Test plan

  • `cargo fmt --all`
  • `cargo test --all` — 1684 passed, 0 failed
  • New regression tests in `src/cmds/system/json_cmd.rs`:
    • `test_extract_schema_eks_cluster_name_is_string_not_date` — `{"clusters": ["my-cluster"]}` → `string`, not `date?`
    • `test_extract_schema_iso_date_still_flagged` — `2024-01-15` → `date?` still works
    • `test_extract_schema_dashed_non_date_strings` — `my-cluster`, `abcd-12-xy`, `foo-bar-ab` all → `string`

Closes #1416

🤖 Generated with Claude Code

…k-ai#1416)

`rtk aws eks list-clusters` rendered cluster names like `my-cluster` as
`date?` in the schema output. The JSON schema extractor's date heuristic
matched any string of length 10 containing `-`, which collides with
plenty of common identifiers (cluster names, slugs, short IDs).

Tightened to a strict `^\d{4}-\d{2}-\d{2}$` regex via lazy_static. ISO
calendar dates are still classified as `date?`; everything else falls
back to `string`.

Closes rtk-ai#1416

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant