Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json!() macro recursion limit reached on larger objects with no nesting #1120

Open
bgmerrell opened this issue Mar 27, 2024 · 0 comments
Open

Comments

@bgmerrell
Copy link

The code below (which I use for unit testing) fails with the error below. If I use serde_json::from_str() the same JSON as a string is parsed with no problems. Is this expected?

The error can be reproduced trivially here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c9b62d7c6508bf68f007336f91e2788a

error: recursion limit reached while expanding `json_internal!`
  --> src/main.rs:2:13
   |
2  |       let _ = serde_json::json!({
   |  _____________^
3  | |         "EnableFeature1": true,
4  | |         "EnforceOperationFoo": true,
5  | |         "EnforceOperationBar": true,
...  |
44 | |         "PropertyPathPrefix": "/etc/foo/bar/baz/company/SOMETHING/my-service"
45 | |     });
   | |______^
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`playground`)
   = note: this error originates in the macro `json_internal` which comes from the expansion of the macro `serde_json::json` (in Nightly builds, run with -Z macro-backtrace for more info)
fn main() {
    let _ = serde_json::json!({
        "EnableFeature1": true,
        "EnforceOperationFoo": true,
        "EnforceOperationBar": true,
        "EnableFeature2": true,
        "DoAThing": true,
        "DoAnotherThing": true,
        "DoSomethingElse": true,
        "DoYetAnotherThing": true,
        "BlockAThing": true,
        "StrictBlockingOfSomething": 12,
        "AllowedNamesOfOtherThings": 13,
        "PollingInterval": 60,
        "MyStatsURL": "http://foo.company.com/usage",
        "AppName": "My Service",
        "EnableRetryForDoingAThing": true,
        "RetryLimitForDoingAThing": 2,
        "MGqlRegistryEndpoint": "http://company.net/foo/bar/baz",
        "RegistryArchivedUrl": "http://foo.bar.k8s.glb.us.company.net/foo/bar",
        "RegistryProviderName": "MY-PROVIDER-NAME",
        "RegistryProviderEnvironment": "prod",
        "ConsumerId": "asdffdaew-dsa8-1245-n324-asdf893asdf893",
        "EnableRegionFeature1": false,
        "FetchDeltaUpdates": false,
        "FooRegistryEndpointTimeout": 60,
        "GatewayClassification": 42,
        "ProviderClassificationEnabled": true,
        "EnableSidecarRequestHook": false,
        "EnableSidecarResponseHook": true,
        "SidecarRoutingConfigIntervalSecs": 300,
        "SidecarKeepAliveSecs": 60,
        "EnableBlockingOfSomeThings": true,
        "DummyFeatureList": 14,
        "RedisClusterEnabled": false,
        "RedisClusterNodes": 15,
        "RedisReadFromReplicas": true,
        "RedisNumberOfRetries": 3,
        "RedisRetryFactor": 2,
        "RedisRetryExponent": 10,
        "RedisMaxRetryWait": 100,
         "RedisMinRetryWait": 10,
        "RedisEnableTlsMode": false,
        "PropertyPathPrefix": "/etc/foo/bar/baz/company/SOMETHING/my-service"
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant