-
Notifications
You must be signed in to change notification settings - Fork 241
Warn when schema.graphql api_version mismatches extension TOML #7098
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,7 +8,7 @@ import {AbortSignal} from '@shopify/cli-kit/node/abort' | |||||
| import {AbortError, AbortSilentError} from '@shopify/cli-kit/node/error' | ||||||
| import lockfile from 'proper-lockfile' | ||||||
| import {dirname, joinPath} from '@shopify/cli-kit/node/path' | ||||||
| import {outputDebug} from '@shopify/cli-kit/node/output' | ||||||
| import {outputDebug, outputWarn} from '@shopify/cli-kit/node/output' | ||||||
| import {readFile, touchFile, writeFile, fileExistsSync} from '@shopify/cli-kit/node/fs' | ||||||
| import {Writable} from 'stream' | ||||||
|
|
||||||
|
|
@@ -124,6 +124,8 @@ export async function buildFunctionExtension( | |||||
| extension: ExtensionInstance, | ||||||
| options: BuildFunctionExtensionOptions, | ||||||
| ): Promise<void> { | ||||||
| await warnIfSchemaMismatch(extension as ExtensionInstance<FunctionConfigType>) | ||||||
|
|
||||||
| const lockfilePath = joinPath(extension.directory, '.build-lock') | ||||||
| let releaseLock | ||||||
| try { | ||||||
|
|
@@ -225,6 +227,30 @@ async function buildOtherFunction(extension: ExtensionInstance, options: BuildFu | |||||
| return runCommand(extension.buildCommand, extension, options) | ||||||
| } | ||||||
|
|
||||||
| const API_VERSION_DIRECTIVE_RE = /@apiVersion\(version:\s*"([^"]+)"\)/ | ||||||
|
||||||
| const API_VERSION_DIRECTIVE_RE = /@apiVersion\(version:\s*"([^"]+)"\)/ | |
| const API_VERSION_DIRECTIVE_RE = /@apiVersion\(version\s*:\s*"([^"]+)"\)/ |
Copilot
AI
Apr 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check currently reads the entire schema.graphql into memory via readFile(schemaPath). The PR description calls out reading only the first ~512 bytes; doing that would keep the check lightweight even if schemas become large. Consider reading a small prefix (e.g. open + read / or readFile then slice) before applying the regex.
Copilot
AI
Apr 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handler in warnIfSchemaMismatch returns for any filesystem error that happens to have a code property (e.g. EACCES/EPERM), which can hide real problems reading schema.graphql and lead to more cryptic failures later in the build. Only ignore the expected “file not found” case (e.g. code === 'ENOENT') and rethrow other read errors.
| if (error instanceof Error && 'code' in error) return | |
| if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new tests cover ENOENT, match, mismatch, and “no directive”, but there’s no assertion for non-ENOENT read failures. Adding a test that
readFilerejects with something like EACCES/EPERM and ensuring the error is propagated would prevent regressions (especially ifwarnIfSchemaMismatchis tightened to only ignore ENOENT).