Skip to content
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

Fastly deploy returns 400 "Failed to extract metadata from package" #1387

Open
GeeWee opened this issue Feb 4, 2025 · 6 comments
Open

Fastly deploy returns 400 "Failed to extract metadata from package" #1387

GeeWee opened this issue Feb 4, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@GeeWee
Copy link

GeeWee commented Feb 4, 2025

Version

Fastly CLI version v10.18.0 (9679de4f)
Built with go version go1.22.11 linux/amd64 (2025-02-04)
Viceroy version: viceroy 0.12.2

What happened

A fastly compute deploy locally on my machine seems to return a 400 from fastly with the error message "Failed to extract metadata from package". The same repository can run the command fine in CI. Anecdotally this is an issue we've seen before, where some coworkers cannot run fastly compute deploy on the exact same repository that others can.

The command with output looks like this:

$ fastly compute deploy -v                          
Fastly API endpoint: https://api.fastly.com
Fastly API token provided via config file (profile: user)

✓ Verifying fastly.toml

Service ID (via fastly.toml): 045GpEZgoLanyYyGdfFpfG

Service version 1416 is not editable, so it was automatically cloned. Now operating on version 1418.

✗ Uploading package

ERROR: the Fastly API returned 400 Bad Request: Bad request (Failed to extract metadata from package).

If you believe this error is the result of a bug, please file an issue: https://github.com/fastly/cli/issues/new?labels=bug&template=bug_report.md

If I use --debug-mode the final response seems to be this:

http.Response (dump): "HTTP/2.0 400 Bad Request\r\nAccept-Ranges: bytes\r\nCache-Control: no-store\r\nContent-Type: application/json\r\nDate: Tue, 04 Feb 2025 08:34:45 GMT\r\nFastly-Ratelimit-Remaining: 986\r\nFastly-Ratelimit-Reset: 1738659600\r\nPragma: no-cache\r\nServer: fastly control-gateway\r\nStatus: 400 Bad Request\r\nStrict-Transport-Security: max-age=31536000\r\nVary: Accept-Encoding\r\nVia: 1.1 varnish, 1.1 varnish\r\nX-Cache: MISS, MISS\r\nX-Cache-Hits: 0, 0\r\nX-Served-By: cache-chi-kigq8000067-CHI, cache-cph2320049-CPH\r\nX-Timer: S1738658047.410536,VS0,VE38506\r\n\r\n"
- Uploading package...
✗ Uploading package

Steps taken to troubleshoot

  • I have tried switching out my access token, and have verified it has access to the service
@GeeWee GeeWee added the bug Something isn't working label Feb 4, 2025
@kpfleming
Copy link
Contributor

If this is reproduceable on your machine, can you attempt to narrow this down by disabling each of the three types of metadata individually, to see which one is triggering the failure?

@GeeWee
Copy link
Author

GeeWee commented Feb 7, 2025

Seems reproducible - at least I still get the error message.

I am unsure about how to disable metadata types individually. This is the output of fastly compute build --metadata-show

$ fastly compute build --metadata-show
✓ Verifying fastly.toml
✓ Identifying package name
✓ Identifying toolchain
✓ Running [scripts.build]

INFO: Below is the metadata attached to the Wasm binary

╭──────────────┬───────────────────────────────────────────────────────────────╮
│ KIND         ┆ VALUE                                                         │
╞══════════════╪═══════════════════════════════════════════════════════════════╡
│ kind         ┆ module                                                        │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ name         ┆ edge_api-6be6cb20ab340c3f.wasm                                │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ range        ┆ 0x0..0x12045b33                                               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ language     ┆ C11                                                           │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ language     ┆ Rust                                                          │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ processed-by ┆ clang [18.1.2-wasi-sdk (https://github.com/llvm/llvm-project  │
│              ┆ 26a1d6601d727a96f4301d0d8647b5a42760ae0c)]                    │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ processed-by ┆ rustc [1.83.0 (90b35a623 2024-11-26)]                         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ processed-by ┆ fastly [v10.18.0 (Rust)]                                      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ processed-by ┆ fastly_data [{"build_info":{"mem_heap_alloc":"10-20MB"},"mach │
│              ┆ ine_info":{},"package_info":{},"script_info":{"build_script": │
│              ┆ "cargo build --bin edge-api --target wasm32-wasip1 --color    │
│              ┆ always \u0026\u0026\nTARGET_DIR=$(cargo metadata              │
│              ┆ --format-version=1 | python3 -c \"import sys, json;
│              ┆ print(json.load(sys.stdin)['target_directory'])\")
│              ┆ \u0026\u0026\nmkdir -p ${TARGET_DIR}/wasm32-wasi/release      │
│              ┆ \u0026\u0026\ncommand cp -f                                   │
│              ┆ ${TARGET_DIR}/wasm32-wasip1/debug/edge-api.wasm               │
│              ┆ ${TARGET_DIR}/wasm32-wasi/release/edge-api.wasm\n"}}]         │
╰──────────────┴───────────────────────────────────────────────────────────────╯


✓ Creating package archive

Trying to build without metadata fails with the same issue.

$ fastly compute build --metadata-disable && fastly compute deploy             
✓ Verifying fastly.toml
✓ Identifying package name
✓ Identifying toolchain
✓ Running [scripts.build]
✓ Creating package archive

SUCCESS: Built package (pkg/edge-api.tar.gz)
✓ Verifying fastly.toml

✗ Uploading package

ERROR: the Fastly API returned 400 Bad Request: Bad request (Failed to extract metadata from package).

If you believe this error is the result of a bug, please file an issue: https://github.com/fastly/cli/issues/new?labels=bug&template=bug_report.md

@kpfleming
Copy link
Contributor

Thanks for those details; given the nature of the error, this will need to be reported to the Fastly Support team as the error is coming from the API endpoint and we'll need to get information from the team who owns it to find out what the cause of the error is.

@kpfleming
Copy link
Contributor

Wait a moment... that 'build script' is substantially more complicated than the usual one and may be breaking the JSON parser. Would you try moving those commands into a shell script and changing the build setting to just invoke that, instead of including all the commands into fastly.toml directly?

@GeeWee
Copy link
Author

GeeWee commented Feb 12, 2025

So! It turns out this was a fun combination of a really bad error message and user error :)

I was accidentally building from our non-prod environment. This doesn't perform a --release build, but rather just a "regular" rust debug build. And apparently that's not something the fastly API will accept.

So, building it with the correct environment (where the only notable difference in the build script is the --release flag) works fine :)

Feel free to close, unless you want to follow up with the API team to make the error message better :)

@kpfleming
Copy link
Contributor

Thank you for the details! We definitely should find a way to improve the error response here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants