← 输入框|github.com|刷新
Skip to content

verify the query text against the persisted query id on cache hits - #4512

Open
nab-iha3 wants to merge 1 commit into
graphql-java:masterfrom
nab-iha3:persisted-query-hash-check-on-hit
Open

nab-iha3 wants to merge 1 commit into
graphql-java:masterfrom
nab-iha3:persisted-query-hash-check-on-hit

Conversation

@nab-iha3

Copy link
Copy Markdown
Contributor

Spock, ApolloPersistedQuerySupportTest on master:

will have error if the query text does not match a query hash that is already cached FAILED
    er.data == null
    |  |    |
    |  |    false
    |  [secret:secret]

PersistedQuerySupport.getDocumentAsync only calls persistedQueryIdIsInvalid from the cache-miss callback. Once a hash is cached, any request carrying it runs the cached document whatever query text it sends: { public } sent with sha256 of { secret } executes { secret } with no error, while ExecutionInput.getQuery() (what instrumentation, logging and the execution id provider see) still says { public }. Apollo's server rejects this case with "provided sha does not match query", and #2395 asked for the same error whenever both a hash and a query are present.

The check now runs before the cache lookup when real query text is sent (not blank, not PERSISTED_QUERY_MARKER). The base persistedQueryIdIsInvalid still returns false, so only ApolloPersistedQuerySupport behaves differently. The existing "hash in preference to query text" test asserted the old behaviour, so it now sends matching text, and new cases cover the mismatch at the unit level and end to end through GraphQL.

@github-actions

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 11 6014 (+2 🟢) 5958 (+2 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 17 6014 (+2 🟢) 5957 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 21 6014 (+2 🟢) 5957 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 25 6014 (+2 🟢) 5957 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 24088 (+8 🟢) 23861 (+8 🟢) 0 (±0) 0 (±0) 227 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 30185 3102 90.7% ±0.0%
Branches 8860 1518 85.4% ±0.0%
Methods 8057 1202 87.0% ±0.0%

Changed Class Coverage (2 classes)

Class Line Branch Method
g.e.i.d.PerLevelDataLoaderDispatchStrategy
$ChainedDLStack
+2.4% 🟢 +4.2% 🟢 ±0.0%
g.e.p.p.PersistedQuerySupport +1.4% 🟢 +2.8% 🟢 +2.4% 🟢

Full HTML report: build artifact jacoco-html-report

Updated: 2026-10-26 13:56:26 UTC

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant