Sign inSign up

avdeb/product-feed-validator

By avdeb

•Updated about 1 month ago

Validate Google Merchant Center product feeds

Image
Content management system
Web analytics
0

198

avdeb/product-feed-validator repository overview

⁠Product Feed Validator

Validate Google Merchant Center product feeds before you upload them. It catches the mistakes that get products disapproved: missing required attributes, malformed prices, invalid GTINs, wrong availability values, broken links and images, and prices that don't match the landing page.

  • Formats: RSS 2.0 and Atom 1.0 XML, TSV, CSV, pipe-delimited. Plain or gzipped, from a file, a URL or stdin
  • 40+ issue types based on Google's product data specification, each with a fix-it message
  • Reports as text, JSON, JUnit XML or GitHub Actions annotations. Exit code 1 on errors, so it can gate CI
  • Optional network checks: landing pages and images respond, images are real images of the minimum size, and the landing page's structured data (JSON-LD or meta tags) shows the same price and availability as the feed
  • Small: one static Go binary with no dependencies, in a distroless image for linux/amd64 and linux/arm64

⁠Quick start

docker run --rm -v "$PWD:/work" avdeb/product-feed-validator products.xml

The current directory is mounted at /work, so pass file names relative to it. On Windows PowerShell use -v "${PWD}:/work".

Product Feed Validator 0.1.0
products.xml · RSS 2.0 · 4 items

Feed
  warning  "image_url" isn't a Merchant Center attribute and will be ignored (1 item). Did you mean "image_link"? [unknown_attribute]

Item 2 · id MUG-002 · line 16
  error    "$14.90" uses a currency symbol. Use the amount and an ISO 4217 currency code, e.g. "15.00 USD". [invalid_price]
  error    gtin "4006381333932" has an invalid check digit (expected 1). Check it for typos. [invalid_gtin_checksum]
  warning  link uses http://; use https:// where possible. [insecure_url]

Item 3 · id STK-001 · line 28
  error    availability_date is required when availability is preorder. [missing_availability_date]
  error    sale_price (4.90 USD) must be lower than price (3.90 USD). [sale_price_not_lower]
  error    id "STK-001" is also used by item 1; every product needs a unique id. [duplicate_id]

────────────────────────────────────────────────────────────
Items   4 total · 0 clean · 4 with errors · 0 with warnings only
Issues  18 errors · 8 warnings · 0 info
Result  ✖ Fix the errors before uploading the feed to Merchant Center.

More examples:

# A feed URL, with link, image and landing-page checks on the first 50 items
docker run --rm avdeb/product-feed-validator -check-urls -check-landing https://example.com/feed.xml

# JSON report for scripts (redirect on the host, the container runs as non-root)
docker run --rm -v "$PWD:/work" avdeb/product-feed-validator -output json products.tsv > report.json

# From stdin, failing on warnings too
gunzip -c feed.xml.gz | docker run --rm -i avdeb/product-feed-validator -fail-on warning -

⁠What it checks

AreaChecks
Required attributesid, title, description, link, image_link, availability, price; unique ids
TextLength limits (title 150, description 5000, id 50, …), ALL CAPS and promotional titles ("free shipping", "20% off"), HTML in titles
Prices15.00 USD format, ISO 4217 currency, currency symbols, comma decimals, price > 0, sale_price lower than price and in the same currency, sale_price_effective_date range
Availabilityin_stock / out_of_stock / preorder / backorder, availability_date for preorder and backorder, ISO 8601 dates, expired expiration_date
IdentifiersGTIN digits, length (8/12/13/14) and GS1 check digit, reserved in-store/coupon prefixes, missing gtin/mpn/brand, conflicting identifier_exists
URLs and imagesAbsolute http(s) URLs, spaces, http vs https, unsupported image types (SVG, PDF), placeholder images, more than 10 additional images
Apparelcolor, gender, age_group (and size for clothing and shoes) when google_product_category is Apparel & Accessories
Valuescondition, gender, age_group, size_type, size_system, adult, is_bundle, multipack, identifier_exists
ShippingCountry codes and prices in shipping
Variantsitem_group_id without variant attributes, duplicate variants in a group
FeedMalformed XML/CSV with line numbers, column-count mismatches, unknown attributes with "did you mean" suggestions (image_url → image_link, colour → color, upc → gtin)
-check-urlsLanding page and image HTTP status, content type, image dimensions (100×100 px, 250×250 px for apparel)
-check-landingFeed price and availability vs the page's schema.org Product offers or product:price meta tags (matches variants by SKU or GTIN)

Severities: error means Merchant Center will likely reject the item or feed. Warning means it can limit performance or is probably a mistake. Info is advice.

⁠Use it in CI

GitHub Actions, with issues shown as annotations on the feed file:

- name: Validate product feed
  run: docker run --rm -v "$PWD:/work" avdeb/product-feed-validator:0.1 feeds/products.xml -output github

JUnit report for CI dashboards:

docker run --rm -v "$PWD:/work" avdeb/product-feed-validator -output junit products.xml > feed-report.xml

Exit codes: 0 passed, 1 issues at or above -fail-on (default error), 2 usage or read error.

⁠Flags

FlagDefault
-formatautoauto, xml, csv or tsv
-output, -otexttext, json, junit or github
-outWrite the report to a file instead of stdout
-fail-onerrorExit 1 on error, warning or never
-max-items50Items listed in the text report (0 = all)
-quietText report: summary only
-no-colorDisable colours (also respects NO_COLOR)
-check-urlsDownload link and image URLs
-check-landingCompare price and availability with the landing page
-network-limit50Max items to run network checks on (0 = all)
-concurrency4Parallel requests for network checks
-timeout15sTimeout per request
-user-agentproduct-feed-validator/<version>User-Agent for HTTP requests

Flags can go before or after the feed argument.

⁠Without Docker

go install github.com/avdeb/product-feed-validator@latest
product-feed-validator products.xml

⁠Limits

The checks follow Google's published product data specification⁠. Some things need your Merchant Center account to check: account-level shipping and tax settings, policy reviews, website verification, and Google's own crawl of your pages. A clean report makes a smooth upload much more likely, but it doesn't guarantee approval.

⁠About

MIT licensed. Issues and pull requests are welcome on GitHub⁠. Made by AVDEB. More free developer tools, a product API and embeds: avdeb.com/developers⁠

Tag summary

Content type

Image

Digest

sha256:fcc38406c…

Size

3.5 MB

Last updated

about 1 month ago

docker pull avdeb/product-feed-validator