chore(testkit): use Arc and DashMap instead of Mutex and HashMap#658
chore(testkit): use Arc and DashMap instead of Mutex and HashMap#658dotansimha merged 4 commits intomainfrom
Arc and DashMap instead of Mutex and HashMap#658Conversation
Summary of ChangesHello @ardatan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the testkit's subgraph service to use Arc<SubgraphsServiceState> with a DashMap for logging requests, replacing the previous Mutex<HashMap> implementation, which improves concurrency and simplifies request tracking. Crucially, this change also remediates a medium-severity Denial of Service (DoS) vulnerability where the service could panic and crash due to an unsafe .unwrap() call when processing malformed JSON bodies; the fix introduces proper error handling. While the use of unwrap_or further enhances robustness, a high-severity issue regarding potential unbounded memory growth in the request log has been identified, violating the repository's style guide.
✅
|
|
🐋 This PR was built and pushed to the following Docker images: Image Names: Platforms: Image Tags: Docker metadata{
"buildx.build.ref": "builder-0aeb9897-f336-445b-91c1-fe5772d073c9/builder-0aeb9897-f336-445b-91c1-fe5772d073c90/t3k9eej0eyorffs8tj2gelg7o",
"containerimage.descriptor": {
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:bdafcbde6cc0010b425d3722f36ba1b7e55c7162ab9d09f45ecc8add9630c2b9",
"size": 1609
},
"containerimage.digest": "sha256:bdafcbde6cc0010b425d3722f36ba1b7e55c7162ab9d09f45ecc8add9630c2b9",
"image.name": "ghcr.io/graphql-hive/router:pr-658,ghcr.io/graphql-hive/router:sha-9c6ab9e"
} |
dotansimha
left a comment
There was a problem hiding this comment.
@ardatan can you please elaborate on the need? I mean, it's all in the test kit and I'm not sure what's the benefit here?
|
@dotansimha I added more sentences to the description. I hope it makes sense. There is no huge benefit. It looks just better to avoid maintaining |
Thanks! Approved |
Extracted from #628
SubgraphServiceStateis cloned together with aMutex<HashMap<in it so instead I made itArc, andDashMapinside of it so no need to deal withMutexetc. AndArc<DashMap<is easier to maintain rather than dealing withlocketc in different places. It will be more future-proof since we consider exporting the testkit for public usage in the future(probably for the plugin system).The other part of changes -> In case of a invalid JSON response from the router,
extract_recordwas failing with a parser error while tracking requests which was leading an invalid result at the end, but now it sets an empty response data.