Skip to content

Conversation

@BrynCooke
Copy link
Contributor

Fixes issues with scientific notation in scripts and json parse.

This updates Rhai to 1.23.6 which includes rhaiscript/rhai#1039 which fixes the scientific notation parsing.

Upgrading Rhai fixes property propagation so that statements such as:

req.headers["auth"].trim() // Fails in subgraph context

will actually try to update the header if a setter is registered.

However in a subgraph context it's not possible to update the header of the supergraph request, this caused an issue with existing scripts as we did register a setter which would error on runtime.

The fix to restore the original behaviour and allow the existing scripts to dispense with all the macro magic that we had and just not register setters for things that can't be set in the appropriate context.

Review guidance:

The first couple of commits upgrade and fix the issue. The original tests pass.
Then I have pulled the functionality out into a separate module and greatly improved the test coverage.

The new code is honestly just easier to reason about without the macros.

During the development process I have regularly downgraded and reintroduced the bug to ensure that we get consistent results.


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

Note any exceptions here

Notes

[ROUTER-1487]: https://apollographql.atlassian.net/browse/ROUTER-1487?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


This is an automatic backport of pull request #8528 done by Mergify.

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@BrynCooke BrynCooke requested a review from a team as a code owner November 6, 2025 14:39
@mergify mergify bot added the conflicts label Nov 6, 2025
@BrynCooke BrynCooke requested review from a team as code owners November 6, 2025 14:39
@mergify
Copy link
Contributor

mergify bot commented Nov 6, 2025

Cherry-pick of 34209e8 has failed:

On branch mergify/bp/2.8.2/pr-8528
Your branch is up to date with 'origin/2.8.2'.

You are currently cherry-picking commit 34209e82.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   .changesets/fix_bryn_upgrade_rhai.md
	modified:   apollo-router/Cargo.toml
	renamed:    apollo-router/src/plugins/rhai/engine.rs -> apollo-router/src/plugins/rhai/engine/mod.rs
	new file:   apollo-router/src/plugins/rhai/engine/registration/execution.rs
	new file:   apollo-router/src/plugins/rhai/engine/registration/mod.rs
	new file:   apollo-router/src/plugins/rhai/engine/registration/router.rs
	new file:   apollo-router/src/plugins/rhai/engine/registration/subgraph.rs
	new file:   apollo-router/src/plugins/rhai/engine/registration/supergraph.rs
	new file:   apollo-router/src/plugins/rhai/engine/types.rs
	modified:   apollo-router/src/plugins/rhai/tests.rs
	new file:   apollo-router/tests/fixtures/test_property_mutations.rhai
	modified:   examples/cookies-to-headers/rhai/src/main.rs

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   Cargo.lock

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot mentioned this pull request Nov 6, 2025
10 tasks
@apollo-librarian
Copy link

apollo-librarian bot commented Nov 6, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 10 changed, 0 removed
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/selectors.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/telemetry-pipelines/trace-exporters/overview.mdx
* graphos/routing/(latest)/operations/subscriptions/overview.mdx
* graphos/routing/(latest)/performance/caching/response-caching/customization.mdx
* graphos/routing/(latest)/performance/caching/response-caching/faq.mdx
* graphos/routing/(latest)/performance/caching/response-caching/observability.mdx
* graphos/routing/(latest)/query-planning/query-planning-best-practices.mdx
* graphos/routing/(latest)/security/cors.mdx
* graphos/routing/(latest)/self-hosted/containerization/aws.mdx
* graphos/routing/(latest)/self-hosted/managed-hosting/railway.mdx

Build ID: b1505135faef4fbcd3aaf19e
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/b1505135faef4fbcd3aaf19e

@BrynCooke BrynCooke force-pushed the mergify/bp/2.8.2/pr-8528 branch from 0e5ea5c to 73d9c86 Compare November 6, 2025 14:50
abernix
abernix previously approved these changes Nov 6, 2025
Co-authored-by: bryn <bryn@apollographql.com>
(cherry picked from commit 34209e8)

# Conflicts:
#	Cargo.lock
@BrynCooke BrynCooke force-pushed the mergify/bp/2.8.2/pr-8528 branch from 73d9c86 to fc913ec Compare November 6, 2025 15:58
@BrynCooke BrynCooke requested a review from abernix November 6, 2025 15:59
@BrynCooke BrynCooke enabled auto-merge (squash) November 6, 2025 16:31
Copy link
Contributor

@aaronArinder aaronArinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@BrynCooke BrynCooke merged commit 14291c9 into 2.8.2 Nov 6, 2025
14 checks passed
@BrynCooke BrynCooke deleted the mergify/bp/2.8.2/pr-8528 branch November 6, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants