Skip to content

fix: send request headers from HTTP helpers and http data source (#80) - #88

Merged
geoffjay merged 1 commit into
mainfrom
fix/issue-80-http-headers
Aug 1, 2026
Merged

fix: send request headers from HTTP helpers and http data source (#80)#88
geoffjay merged 1 commit into
mainfrom
fix/issue-80-http-headers

Conversation

@geoffjay

@geoffjay geoffjay commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #80 — the Rhai HTTP helpers and the http data source had no way to set request headers, so a config could not send Authorization: Bearer <token> (or any custom header) and every authenticated call failed.

Changes

  • Rhai helpers (crates/nemo-extension/src/rhai_engine.rs): execute_http_request gained an optional headers map, and each helper got a header-accepting arity:

    • http_get(url, #{…}), http_delete(url, #{…})
    • http_post(url, body, #{…}), http_put(url, body, #{…})

    A caller-supplied Content-Type overrides the JSON default applied to request bodies. Headers are flattened to owned string pairs before the async boundary since rhai::Dynamic is !Send.

  • http data source (crates/nemo-data/src/sources/mod.rs): the factory previously parsed only url/interval and silently dropped method/headers/body, even though HttpSourceConfig and fetch() already applied them. It now parses all three. New parse_http_headers accepts either a config object or a JSON-string attribute. ${env.X} / ${var.x} in header values are resolved by the config resolver at load time.

  • Schema (crates/nemo-registry/src/builtins.rs): added headers and body to the http data source schema so configs validate.

Usage

http_post(url, body, #{ "Authorization": "Bearer " + token })
<source name="secure" type="http" url="https://api.example.com/me"
        headers='{"Authorization":"Bearer ${env.API_TOKEN}"}' />

Testing

  • Affected crates build clean; clippy + fmt clean (pre-commit hooks passed).
  • Added 3 parse_http_headers unit tests (object / JSON-string / none); nemo-registry and nemo-extension suites green.

Docs updated: KB data-flow.md, extensions.md, log.md; the nemo-xml-reference skill; and docs/public/configuration.md.

🤖 Generated with Claude Code

The Rhai HTTP helpers and the `http` data source had no way to set request
headers, so configs could not send `Authorization: Bearer <token>` or any
custom header.

- rhai_engine.rs: add an optional trailing `headers` map to
  http_get/http_post/http_put/http_delete; a caller-supplied Content-Type
  overrides the JSON default.
- sources/mod.rs: the `http` factory now parses `method`, `headers`, and
  `body` (previously silently dropped); new parse_http_headers accepts a
  config object or a JSON-string attribute. `${env.X}`/`${var.x}` in header
  values are resolved by the config resolver at load time.
- builtins.rs: add `headers` and `body` to the `http` data source schema.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.24390% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.45%. Comparing base (82b766c) to head (b34f408).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/nemo-extension/src/rhai_engine.rs 0.00% 43 Missing ⚠️
crates/nemo-data/src/sources/mod.rs 83.78% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #88      +/-   ##
==========================================
- Coverage   56.59%   56.45%   -0.14%     
==========================================
  Files          78       78              
  Lines        6866     6943      +77     
==========================================
+ Hits         3886     3920      +34     
- Misses       2980     3023      +43     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@geoffjay
geoffjay merged commit 6e7b338 into main Aug 1, 2026
5 of 7 checks passed
@geoffjay
geoffjay deleted the fix/issue-80-http-headers branch August 1, 2026 16:30
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.

HTTP helpers and http data source cannot send request headers (no auth/bearer support)

1 participant