Skip to content

fix(es): accept REST-style bodies for index and create - #493

Draft
margaretjgu wants to merge 3 commits into
mainfrom
fix/rest-style-body-index-create
Draft

fix(es): accept REST-style bodies for index and create#493
margaretjgu wants to merge 3 commits into
mainfrom
fix/rest-style-body-index-create

Conversation

@margaretjgu

Copy link
Copy Markdown
Member

Summary

Closes #360. es index and es create now accept REST-style bodies piped via stdin (e.g. echo '{"name":"test"}' | elastic es index --index test --id 1). When the stdin JSON is missing the document wrapper key, it is automatically wrapped before schema validation runs. Commands that already provide the {"document": {...}} wrapper are unaffected.

Test plan

  • echo '{"name":"test"}' | elastic es index --index test --id 1 no longer errors with input validation failed
  • echo '{"document":{"name":"test"}}' | elastic es index --index test --id 1 still works
  • Unit tests: inputTransform in factory.test.ts, REST-style body in register.test.ts
  • Full test suite passes (npx tsx --test test/**/*.test.ts)

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 0.97s
✅ REPOSITORY gitleaks yes no no 60.18s
✅ REPOSITORY git_diff yes no no 0.05s
✅ REPOSITORY secretlint yes no no 30.14s
✅ REPOSITORY trivy yes no no 17.69s
✅ TYPESCRIPT eslint 6 0 0 6.44s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@margaretjgu
margaretjgu marked this pull request as draft July 30, 2026 17:41
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.

es index/create: accept REST-style bodies (follow-up to #95 / #130)

1 participant