Skip to content

Don't exclude resources/generator-config.json from package archives - #906

Merged
jlevers merged 1 commit into
jlevers:mainfrom
DaveLegg:fix/restore-generator-config-export
Jul 29, 2026
Merged

Don't exclude resources/generator-config.json from package archives#906
jlevers merged 1 commit into
jlevers:mainfrom
DaveLegg:fix/restore-generator-config-export

Conversation

@DaveLegg

@DaveLegg DaveLegg commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

#903 marked resources/generator-config.json export-ignore in .gitattributes alongside genuinely dev-only files (tests/, resources/models/, resources/apis.json, resources/metadata/). Unlike those, this file is read at runtime:

// src/Generator/Package.php
public static function version(): string
{
    $config = json_decode(file_get_contents(GENERATOR_CONFIG_FILE), true);
    return $config['version'];
}

and SellingPartnerApi::defaultUserAgent() calls Package::version() on every single request to build the User-Agent header:

$version = Package::version();
$this->userAgent = "jlevers/selling-partner-api/v$version/php";

Since v7.4.9, anyone installing via Composer gets a package archive missing this file, so every SP-API request fatals:

file_get_contents(.../resources/generator-config.json): Failed to open stream: No such file or directory
Thrown in .../src/Generator/Package.php on line 14

I checked whether the other newly-excluded resource files (apis.json, metadata/**, models/**) are also read outside src/Generator/ at runtime - they aren't (only resources/feeds.json and resources/reports.json are read at runtime, via DownloadsDocument/UploadsDocument/RestrictedReport, and neither of those is in the export-ignore list), so this is the one file that needs to come back.

Verified with git archive HEAD --format=zip that the file is included in the resulting archive after this change.

Reports the same underlying issue as #906.

Package::version() and Package::namespace() read this file at runtime
(via the GENERATOR_CONFIG_FILE constant), and SellingPartnerApi::defaultUserAgent()
calls Package::version() on every request to build the User-Agent header.
jlevers#903 marked this file export-ignore alongside genuinely dev-only files
(tests/, resources/models/, resources/apis.json, resources/metadata/),
so every v7.4.9 install via Composer is missing a file the SDK requires
at runtime, and every SP-API request fatals with:

  file_get_contents(.../resources/generator-config.json): Failed to
  open stream: No such file or directory
@jlevers

jlevers commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Jesus, thanks for the catch. Merging and cutting a new release now

@jlevers
jlevers merged commit fb0e998 into jlevers:main Jul 29, 2026
2 checks passed
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.

2 participants