{"record":{"id":"ed73109c088e884a","repo":"linera-io/linera-protocol","slug":"count-exceeds-u32-ed7310","errorCode":null,"errorMessage":"count exceeds u32","messagePattern":"count exceeds u32","errorType":"http","errorClass":"async_graphql::Error","httpStatus":null,"severity":"error","filePath":"linera-views/src/views/set_view.rs","lineNumber":1002,"sourceCode":"\n    #[async_graphql::Object(cache_control(no_cache), name_type)]\n    impl<C, I> SetView<C, I>\n    where\n        C: Context,\n        I: Send + Sync + Serialize + DeserializeOwned + async_graphql::OutputType,\n    {\n        async fn elements(&self, count: Option<usize>) -> Result<Vec<I>, async_graphql::Error> {\n            let mut indices = self.indices().await?;\n            if let Some(count) = count {\n                indices.truncate(count);\n            }\n            Ok(indices)\n        }\n\n        #[graphql(derived(name = \"count\"))]\n        async fn count_(&self) -> Result<u32, async_graphql::Error> {\n            let count = self.iterative_count().await?;\n            u32::try_from(count).map_err(|_| async_graphql::Error::new(\"count exceeds u32\"))\n        }\n    }\n\n    impl<C: Send + Sync, I: async_graphql::OutputType> async_graphql::TypeName for CustomSetView<C, I> {\n        fn type_name() -> Cow<'static, str> {\n            format!(\n                \"CustomSetView_{}_{:08x}\",\n                mangle(I::type_name()),\n                hash_name::<I>(),\n            )\n            .into()\n        }\n    }\n\n    #[async_graphql::Object(cache_control(no_cache), name_type)]\n    impl<C, I> CustomSetView<C, I>\n    where\n        C: Context,","sourceCodeStart":984,"sourceCodeEnd":1020,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-views/src/views/set_view.rs#L984-L1020","documentation":"The GraphQL schema generated for `SetView` exposes a derived `count` field typed u32, backed by `iterative_count()` (a `usize`). If the set holds more than `u32::MAX` elements the `u32::try_from` fails and the resolver returns 'count exceeds u32'. This is a schema-limit guard for sets beyond ~4.29 billion elements.","triggerScenarios":"Querying `count` on a SetView accumulated past 4,294,967,295 elements (e.g. a per-transaction membership set that is never pruned).","commonSituations":"Unbounded set growth in long-running applications; synthetic tests filling a set past the u32 boundary.","solutions":["Use `elements(count: n)` to page through the set instead of requesting `count`.","Prune or expire set elements so the set stays within representable size.","Keep an application-level u64 counter rather than relying on the derived `count`.","Ask upstream to widen the field if >2^32 elements is legitimate."],"exampleFix":"# before\nquery { app { state { participants { count } } } }  # fails past u32::MAX\n\n# after\nquery { app { state { participants { elements(count: 1000) } } } }  # paginate; maintain participantCount in app state","handlingStrategy":"fallback","validationCode":"# sets expose elements(count:) paging\nquery { app { state { participants { elements(count: 1) } } } }","typeGuard":null,"tryCatchPattern":"try { return await gql.query('query { app { state { participants { count } } } }'); } catch (e) { if (/count exceeds u32/i.test(e.message)) { return tallyViaPagedElements('participants'); } throw e; }","preventionTips":["Expire stale set members.","Maintain a u64 membership counter in app state.","Use elements(count:) paging in UIs."],"tags":["graphql","views","count","u32-overflow","set-view"],"backgroundTag":"integer-overflow","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}