Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions nsc/cli/writes/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,13 @@ def _cast_bool(value: Any) -> Any:
return value


_OTHER_SENSITIVE_HEADERS = SENSITIVE_HEADERS - {"authorization"}


def _redact(headers: dict[str, str]) -> dict[str, str]:
out: dict[str, str] = {}
for k, v in headers.items():
if k.lower() == "authorization":
lowered = k.lower()
if lowered == "authorization":
out[k] = _REDACTED_AUTH
elif k.lower() in _OTHER_SENSITIVE_HEADERS:
elif lowered in SENSITIVE_HEADERS:
out[k] = "<redacted>"
else:
out[k] = v
Expand Down
6 changes: 3 additions & 3 deletions nsc/cli/writes/bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ def run_loop(
attempts.append(LoopAttempt(request=request, response=None, failure=failure))
if on_error == "stop":
break
continue
audit_attempt(request, response, None)
attempts.append(LoopAttempt(request=request, response=response, failure=None))
else:
audit_attempt(request, response, None)
attempts.append(LoopAttempt(request=request, response=response, failure=None))
return LoopResult(attempts=attempts)


Expand Down
6 changes: 1 addition & 5 deletions nsc/cli/writes/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def collect(
used_file = True

field_overlay = _parse_fields(fields)

records = _merge(file_records, field_overlay, used_file=used_file)

source: Literal["file", "stdin", "fields_only", "file_plus_fields"]
if used_stdin:
source = "stdin"
Expand Down Expand Up @@ -232,9 +232,7 @@ def _classify_brace_start(stripped: str) -> str:
if depth == 0:
rest = stripped[i + 1 :]
if rest.strip():
# Any non-whitespace after the first object → NDJSON.
return "ndjson"
# Nothing follows → single object.
return "json_or_yaml"
# Buffer ended mid-object; default to JSON-or-YAML.
return "json_or_yaml"
Expand All @@ -254,13 +252,11 @@ def _parse_text(text: str, *, hint: str | None) -> tuple[list[dict[str, Any]], b
if hint == "ndjson":
return _parse_ndjson(text), True
if hint == ".json":
# File-extension was .json; require strict JSON, no YAML fallback.
try:
parsed = json.loads(text)
except json.JSONDecodeError as exc:
raise InputError(f"could not parse JSON input: {exc}") from exc
elif hint == "json_or_yaml" or (hint is None and text.lstrip().startswith(("{", "["))):
# Stdin sniffer hint OR legacy fallback: try JSON first, then YAML.
try:
parsed = json.loads(text)
except json.JSONDecodeError:
Expand Down
1 change: 0 additions & 1 deletion nsc/cli/writes/preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def _check_required(index: int, record: dict[str, Any], body: RequestBodyShape)
field_path=name,
kind="missing_required",
message=f"required field {name!r} is missing",
expected=None,
)
for name in body.required
if name not in record
Expand Down
Loading