fix: send request headers from HTTP helpers and http data source (#80) - #88
Merged
Conversation
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #80 — the Rhai HTTP helpers and the
httpdata source had no way to set request headers, so a config could not sendAuthorization: Bearer <token>(or any custom header) and every authenticated call failed.Changes
Rhai helpers (
crates/nemo-extension/src/rhai_engine.rs):execute_http_requestgained 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-Typeoverrides the JSON default applied to request bodies. Headers are flattened to owned string pairs before the async boundary sincerhai::Dynamicis!Send.httpdata source (crates/nemo-data/src/sources/mod.rs): the factory previously parsed onlyurl/intervaland silently droppedmethod/headers/body, even thoughHttpSourceConfigandfetch()already applied them. It now parses all three. Newparse_http_headersaccepts 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): addedheadersandbodyto thehttpdata source schema so configs validate.Usage
Testing
parse_http_headersunit tests (object / JSON-string / none); nemo-registry and nemo-extension suites green.Docs updated: KB
data-flow.md,extensions.md,log.md; thenemo-xml-referenceskill; anddocs/public/configuration.md.🤖 Generated with Claude Code