Skip to content

fix: reject container access through null JSON fields - #1981

Open
Rexyysilent wants to merge 1 commit into
httpie:masterfrom
Rexyysilent:codex/reject-null-json-container-access
Open

Rexyysilent wants to merge 1 commit into
httpie:masterfrom
Rexyysilent:codex/reject-null-json-container-access

Conversation

@Rexyysilent

@Rexyysilent Rexyysilent commented Oct 22, 2026 •

Copy link
Copy Markdown

Accessing a child of a null-valued JSON object member silently replaces the whole request body. This offline command currently prints only {"bar": "baz"}, dropping both keep and foo:

http --offline --print=B example.org keep=value foo:=null 'foo[bar]=baz'

Initialize the root context before walking the path, so a nested None reaches the existing type check. The command then reports HTTPie Type Error at foo[bar] and exits with status 1, consistent with the documented nested JSON type checks.

The tests cover key, index, and append access through null object members at three nesting positions. All nine regression cases fail before the fix and pass afterward. Three additional cases check that ordinary null values, direct value overrides, and filling sparse array entries still work. The changelog describes the corrected behavior.

Validation on Windows / Python 3.13.14:

  • 372 passed across test_json, test_offline, test_cli, test_cli_utils, test_cli_ui, test_errors, and test_parser_schema.
  • The repository's full make codestyle Flake8 command passed (run directly on Windows).
  • The standalone offline reproduction reports the expected diagnostic and exit status.

Prepared with OpenAI Codex assistance. Commit credit: @Rexyysilent, with a Codex co-author trailer.

model_string: OpenAI_DaybreakAstra is a user-requested custom attribution label, not verified runtime model metadata.

CI note: the Ubuntu / Python 3.7 job currently fails in actions/setup-python, before tests run, because Python 3.7 is unavailable for Ubuntu 24.04 (job log). The remaining checks are still in progress.

Further CI results: Ubuntu / Python 3.11 reached 1,029 passed, with only the two Big5 charset-detection tests failing (job log). Both failures also reproduce locally with the original, unmodified JSON interpreter. A PyOpenSSL-enabled job additionally fails two existing digest-auth tests because an SSL context cannot be mutated after use (job log). These CI failures are recorded here rather than claimed as passing.

Initialize the root context before walking a nested JSON path. A null
object member then reaches the existing type checks instead of replacing
the entire root and discarding previously supplied request fields.

Cover key, index, and append access in nested objects and top-level
arrays, plus null values, direct overrides, and sparse array filling.

Co-authored-by: Codex <noreply@openai.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