Skip to content

Validate README data source URLs against city data (#628) - #791

Open
alexschnapper wants to merge 1 commit into
wo-ist-markt:masterfrom
alexschnapper:backend/validate-data-source-urls-628
Open

Validate README data source URLs against city data (#628)#791
alexschnapper wants to merge 1 commit into
wo-ist-markt:masterfrom
alexschnapper:backend/validate-data-source-urls-628

Conversation

@alexschnapper

@alexschnapper alexschnapper commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Saw the issue from @johnjohndoe which was there since a couple of years and gave it a look and thought I might help and created this PR. If not needed, just let me know 😁

This pull request adds an automated validation that ensures the data source URL documented for each city in README.md matches the URL stored in the corresponding cities/*.json file.

It also synchronizes the currently divergent README links with the city data.

Closes #628.

Changes

  • Add spec/data-source-url.test.js.

  • Parse the supported-cities table and Markdown link definitions from README.md.

  • Match every README entry to its corresponding city in cities/cities.json.

  • Compare the README URL with metadata.data_source.url from the city JSON file.

  • Fail the existing test workflow when:

    • a city cannot be matched;
    • the README does not contain one data source per city; or
    • the two URLs differ.
  • Normalize city names to handle:

    • umlauts and their transliterations;
    • regional suffixes such as (Rheinland) or (Taunus); and
    • minor naming differences between the README and cities.json.
  • Treat Markdown reference labels case-insensitively, as Markdown itself does.

  • Synchronize 35 stale README data source URLs with their city JSON counterparts.

  • Treat cities/cities.json and the corresponding city files as the source of truth.

  • Check the relationship in both directions:

    • every configured city must have exactly one README entry;
    • every README data source must belong to exactly one configured city; and
    • the corresponding URLs must match.
  • Parse the supported-cities table and Markdown reference definitions with small, documented parsing helpers.

Findings

Issue #628 was created in January 2024 and is still open without comments. A review of the current codebase, commit history, and related pull requests did not find an existing implementation of the requested README-to-JSON validation.

Several later pull requests updated individual data source URLs, but the README and city JSON files continued to be maintained independently. This caused the two sources to diverge over time.

The initial validation found 35 inconsistent README references. These included outdated URLs, HTTP-to-HTTPS changes, moved city pages, and different URL paths.

It also exposed an existing content error:

  • The README reference for Gelsenkirchen pointed to the Essen weekly markets URL.
  • The Gelsenkirchen reference now matches cities/gelsenkirchen.json.

The existing Gelsenkirchen and Kaiserslautern Markdown reference labels use different capitalization from their references in the city table. The test therefore compares Markdown reference labels case-insensitively.

edit:
The initial validation found 35 mismatches, including outdated URLs, HTTP-to-HTTPS changes, moved pages, different URL paths, and the Gelsenkirchen entry.

The previous Gelsenkirchen README URL may have been valid historically because markets for nearby cities can be maintained by the same provider. This PR does not make a judgment about that historical URL; it updates the README to match the current source-of-truth value in cities/gelsenkirchen.json.

Why this approach

The validation compares URLs per city instead of comparing only the combined set of URLs.

A set-based comparison could incorrectly pass if two cities had exchanged URLs. Matching each README entry to its city JSON file ensures that the correct URL belongs to the correct city and produces a useful city-specific failure message.

The test uses only Node.js built-in modules and is included automatically in the existing npm test command through the current node --test spec/**.test.js configuration.

Validation

  • node --test spec/**.test.js

    • 9 tests passed
    • 0 tests failed
  • git diff --check

    • passed
  • Branch comparison:

    • one commit ahead of master
    • no unrelated files changed

The complete npm test and build commands could not be completed in the Codex environment because npm repeatedly failed while extracting registry tarballs from its cache. This failure occurred during dependency installation and was unrelated to the implementation.

The new validation itself and the existing dependency-free Node.js test suite pass successfully.

@alexschnapper
alexschnapper marked this pull request as ready for review August 13, 2026 10:05
Comment thread spec/data-source-url.test.js Outdated
Comment thread spec/data-source-url.test.js Outdated
Comment thread README.md
[fuerth-markets]: https://www.fuerthwiki.de/wiki/index.php/Kategorie:M%C3%A4rkte
[Gelsenkirchen-wikipedia]: https://en.wikipedia.org/wiki/Gelsenkirchen
[Gelsenkirchen-markets]: https://essener-wochenmaerkte.de
[Gelsenkirchen-markets]: https://www.gelsendienste.de/privathaushalte/maerkte/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was likely not wrong. Gelsenkirchen is near Essen - markets might have been maintained on that website.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. You are right that the previous URL was not necessarily incorrect merely because it used the Essen markets domain.

The PR updates the README to match the current data_source value in cities/gelsenkirchen.json, which is the consistency this validation enforces. I have adjusted the PR description so it no longer describes the previous URL as a confirmed content error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to replace the former text. GitHub keeps a version history of the text anyway.

@johnjohndoe johnjohndoe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash your commits and only update the single commit.

return dataSources;
}

function readCityDataSources() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the helper function be private?

Comment thread spec/data-source-url.test.js Outdated
});
}

test('each configured city data source is documented in README', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the test function to the top and the "not so important" helper functions to the bottom?

@alexschnapper
alexschnapper force-pushed the backend/validate-data-source-urls-628 branch from 4b8cf80 to 8977203 Compare August 17, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate that URLs in README.md and city.json match

2 participants