# Changelog of France Company Registry Scraper — SIREN & NAF Data (`stone_jadex/france-company-registry-scraper`) Actor

- **URL**: https://apify.com/stone_jadex/france-company-registry-scraper/changelog.md
- **Full Actor documentation**: https://apify.com/stone_jadex/france-company-registry-scraper.md

## Changelog

### 0.1.10 — 2026-11-21

- Input schema UX polish: added `sectionCaption` / `sectionDescription` groupings across all six logical filter/option groups and explicit `prefill: 100` on `maxItems` (alongside existing `prefill: "boulangerie"` on `query`), preserving 100% compatibility with online schema `0.1.8` and all existing input contracts.
- README polish: documented live Apify Store subscription tier discounts (`Free` through `Diamond`), added JavaScript & Python `ApifyClient` SDK quickstart (`Stone_JadeX/france-company-registry-scraper`), and added `2026-11-21` Changelog section.

### Unreleased (linear fix: truncatedAtApiCap, legalName null, matchingEstablishments)

- Fix: `truncatedAtApiCap` (and the radius truncation warning / run-notice note) is true only when a `/near_point` search actually exhausts the API 10,000-result cap. If `maxItems` stops the run first, or the query is an ordinary `/search`, the flag stays false. (red: redlogs/38-linear-fix.red.log; green: .green.log; mutations: .mut.log)
- Fix: `legalName` is null when `nom_raison_sociale` is missing, an empty string, or whitespace-only (trimmed).
- Feat (add-only): radius rows always include `matchingEstablishments`, mapped from this response's `matching_etablissements` with the same shape as `establishments` (siret, address, coordinates, isHeadOffice, …). No extra request and no extra charge. Official `/near_point` semantics: matches are establishments inside the radius; the head office on the main row may lie outside. Non-radius rows set the field to null. `establishments` is unchanged (still opt-in via `includeEstablishments`). A `/near_point` request now sends `limite_matching_etablissements=100` on the same call so the list is present; `radius` is still forwarded when `radiusKm` is set. Handoff updated: docs/handoff/2026-11-11-final-rework.md.

### Unreleased (终验返工 D1–D7 + legalName)

- Fix (D1): a `/near_point` radius search that hits the API 10,000-result cap is no longer split by département or postcode (those filters are ignored by that endpoint, which produced duplicate rows and a fake "Postcode 10000" warning). The same query is paginated up to min(maxItems, 10000) and truncated honestly. OUTPUT and the run-notice set `truncatedAtApiCap` and a `truncationNote` asking the user to narrow the radius. (red: redlogs/37-final-rework.red.log; green: .green.log; mutations: .mut.log)
- Fix (D2): `radiusKm` without lat/lon is `invalid-input` (nothing charged, no run-notice), same path as other illegal input. It is no longer silently ignored.
- Fix (D3): `extraParams` cannot override pagination. `page`, `per_page`, `page_size`, `offset`, `limit`, `limite`, `cursor`, `start`, `from`, `size` and `debut` are dropped with a warning. Birth-date keys stay silently blocked. Other keys such as `est_bio` are still forwarded.
- Fix (D4): when `total_results` is the API cap of 10000, the count-preview status says `Count preview: at least 10,000 companies match the input. Nothing was charged.` `totalResults` stays 10000 and `totalResultsIsLowerBound` is true.
- Fix (D5): an HTTP 200 HTML challenge or verification page (non-JSON body with challenge markers, e.g. `<html>captcha</html>`) stops as `blocked-challenge` and writes a run-notice. Valid JSON missing `results`, and other malformed bodies, stay `bad-page-structure`.
- Fix (D6): when rows were charged but `pushData` failed (`chargedButNotPushed` > 0, 0 rows written, run not failed), the status no longer says "Nothing was charged." It says the rows were charged but could not be saved (`OUTPUT.chargedButNotPushed`).
- Tests (D7): characterisation tests kill the final-review survivors C01 (radius max 50), C02 (radius 0 rejected), C05 (lon wins over long), C06 (typePersonne passed through, not lowercased) and C04b (robots.txt HTTP 5xx continues).
- Feat (add-only): dataset field `legalName` is the API `nom_raison_sociale` (null if omitted). `name` is unchanged (`nom_complet` then `nom_raison_sociale`). No VIES or BODACC. Event name `result-row` and price $0.00175 are unchanged.
- Schema (enough for tests; further polish is for the structured-output officer): input_schema countOnly / radiusKm / extraParams descriptions (L112, L133, L177); dataset `legalName` and notice truncation fields; OUTPUT `truncatedAtApiCap`, `totalResultsIsLowerBound`, `truncationNote`; stopReason `blocked-challenge`. Handoff: docs/handoff/2026-11-11-final-rework.md.

### Unreleased (PPE file aligned to live $0.00175; count-preview and 412 intercept)

- Chore (not a price change; 幕僚 citing jade 14:41 "France 先不涨价"): `.actor/pay_per_event.json` `result-row` is aligned from the stale file price $0.004 to the live Store price $0.00175 per row ($1.75 per 1,000). The event name is unchanged. README already quotes $1.75/1,000 and was not edited. Red: redlogs/35-ppe-align-00175.red.log; mutation: 35-ppe-align-00175.mut.log.
- Fix: a `countOnly` / `count-preview` run now sets statusMessage to `Count preview: <N> companies match the input. Nothing was charged.` instead of `No companies matched the input (count-preview)`.
- Fix: `countOnly` with a SIREN list does not treat the first SIREN as a count. `totalResults` stays null, a warning says count preview applies only to search filters, `stopReason` is still `count-preview`, 0 rows are written and nothing is charged. On a normal (non-preview) run, `totalResults` is still the total from the first search request.
- Fix: HTTP 412 is listed in the `crawlQuery` intercept with 403/429 (same path: backoff of at least 30s, twice, then the run stops with `blocked-412`). Confirmed the source no longer produces `http-429` (429 is `blocked-429`). Unchanged: a numeric status is `blocked-<n>`; a login redirect with no status is `blocked-login-redirect`; 5xx still backs off 30s then 60s and then stops. Red: redlogs/36-count-preview-412.red.log; mutations: 36-mut-count-preview-message.log, 36-mut-siren-count-first.log, 36-mut-412-not-in-intercept.log, 36-mut-http-429.log.

### Unreleased (review 00cdfd3 non-blocking 3)

- Fix (QA, same bug as companies-house 6f029cf): warnings were never written to the run log online. The entry passed `Actor.log || console`, but `Actor.log` is undefined in apify 3.7.2 and `console.warning` does not exist, so every `log.warning?.()` did nothing. main.js now imports `log` from apify and passes it to run(). run(), http.js `createClient` and billing.js `createBiller` default to that log instead of console, so robots, refusal, network and pushData-retry warnings are actually emitted. Code only; output fields unchanged. New test test/real-apify-log.test.js uses the real apify export with no mocked Actor.log: it asserts that `log.warning` exists and `Actor.log` is undefined, that src/ has no `Actor.log` and no console default, and it spies on the real `log.warning` for a billing retry and a refused URL. Redlogs 33-real-apify-log (red/green; .mut.log restores the old entry and goes red).
- Docs: README Pricing now has a same-basis cost-per-1,000-rows comparison: ours $4.00 (draft price $0.004, may change) vs dltik/pappers-sirene-scraper $8.00 (found in the Store, 175 users, so no substitute was needed), corent1robert/recherche-entreprises-scraper $5.99 and epicscrapers/pappers-scraper $4.00. All are Free-tier event prices read from the public Apify Store API on 2026-11-01; the raw responses are in redlogs/pricing-20261101/. A test checks the section and that each quoted price matches the saved response (red: redlogs/32-pricing-comparison.red.log, green: .green.log).
- Investigated: in a split, a sub-query that hits the page cap returns `api-cap` to the split loop, which (by design) moves on to the remaining sub-queries, so the run ends with `no-more-results`. Kept that `stopReason` (it describes how the whole run ended; values unchanged) and report the page cap consistently through `OUTPUT.pageCapQueries` and the status message `Page cap reached on N queries`. Documented in the README FAQ. Tests only for code: new split test (green: redlogs/31-split-page-cap-consistency.green.log; mutations of the counter and of the split loop each turn it red: mutation-logs/25).

### Unreleased (review 00cdfd3 non-blocking 2)

- When an HTTP error or malformed response stops the run after rows were delivered (e.g. a later-page 5xx), the status message adds `Stopped on error: <error> (see OUTPUT.errors).`. Added OUTPUT field `stoppedOnError` (boolean). `stopReason` values unchanged (red: redlogs/30-stopped-on-error-status.red.log; mutation: mutation-logs/24).

### Unreleased (review 00cdfd3 non-blocking 1)

- Tests only, for the untested count branches: later-page 5xx => `failedQueries` 0 and `pageCapQueries` 0; first-page malformed 200 with rows => `failedQueries` 1; later-page malformed 200 => `failedQueries` 0. Already correct, so there is no red run; 3 mutations each turn 1 test red (mutation-logs/23; green: redlogs/29-count-branches.green.log).

### Unreleased (review 14c50a4 non-blocking 3)

- `failedQueries` is counted explicitly per query (counter in `run()`, set in `finish()`); the status message no longer falls back to `errors.length` (red: redlogs/28-failed-queries-explicit.red.log; mutation: mutation-logs/22 sets `failedQueries = errors.length` => 1 red).

### Unreleased (review 14c50a4 non-blocking 2)

- A later-page HTTP 400 (API page cap, earlier pages delivered) is no longer counted in `failedQueries`. It is counted in an added OUTPUT field `pageCapQueries`, and the status message says `Page cap reached on N queries (...)` separately from `N queries failed`. `failedQueries` now counts only queries that failed on their first page (HTTP error, 400 or malformed response). Documented in the README FAQ (red: redlogs/27-page-cap-vs-failed.red.log; mutation: mutation-logs/21).

### Unreleased (review 14c50a4 non-blocking 4)

- Status message uses the singular `Done: 1 company (...)`; 2+ rows still say `companies` (red: redlogs/26-singular-company.red.log).

### Unreleased (review 14c50a4 non-blocking 1)

- Tests only: status message uses the singular `1 query failed` and never `1 queries`. Already correct, so there is no red run; mutation to always-plural turns it red (mutation-logs/20; green: redlogs/25-singular-query.green.log).

### Unreleased (review 5136985 non-blocking 3)

- Refactor: removed the redundant `!out.rowsPushed` check in the `invalid-sirens` status branch (that stop reason is only set before any search, so rows are always 0). No behaviour change; existing tests stay green.

### Unreleased (review 5136985 non-blocking 2)

- Tests only: split sub-query page-1 HTTP 400 then continue => charged == rows (each row once), `failedQueries` 1, OUTPUT and status written once. Behaviour already existed, so there is no red run; double-charge and double-OUTPUT mutations turn it red (mutation-logs/19; green: redlogs/24-split-400-charge-once.green.log).

### Unreleased (review 5136985 non-blocking 1)

- When rows were delivered but some queries failed, the status message now appends `N queries failed (see OUTPUT.errors).` (e.g. `Done: 3 companies (no-more-results). 2 queries failed (see OUTPUT.errors).`). `stopReason` values are unchanged. OUTPUT gains an added field `failedQueries` (count of recorded errors, 0 when none); nothing renamed or removed (red: redlogs/23-status-failed-queries.red.log; mutation: mutation-logs/18).

### Unreleased (review ffdeecd fix 2 required tests)

- Tests only, for continuing after a SIREN's page-1 HTTP 400: (a) the error names the URL and the API message, and the next SIREN is still fetched; (b) every query 400 with 0 rows => FAILED (`invalid-filter`), nothing charged, OUTPUT written once; (c) some rows + some 400s => `no-more-results`, charged == rows, no double charge, OUTPUT and status written once. Behaviour already existed (c766456), so there is no red run; mutations M1-M3, M4b and M5 each turn tests red (mutation-logs/17; M4 in that log hit the wrong code block and is kept as a note; green: redlogs/22-page1-400-continue-extra.green.log).

### Unreleased (review ffdeecd non-blocking 5)

- Refactor: removed the dead zero-padding (`padStart`) in `normSiren()` (src/input.js); it only receives values that already passed the 9-digit check. No behaviour change; existing SIREN tests stay green.

### Unreleased (review ffdeecd non-blocking 4)

- When every input SIREN is malformed, the status message now says no search was run because the SIREN format was invalid (must be exactly 9 digits) and lists the values, instead of "No companies matched". OUTPUT gains an added field `invalidSirens` (only present when malformed SIRENs were given); no field renamed or removed (red: redlogs/21-invalid-sirens-status.red.log; mutation: mutation-logs/16).

### Unreleased (review ffdeecd non-blocking 3)

- Tests only: the README sample-row test now compares every scalar field (strings, numbers, booleans, null) against `transformCompany` output, not just strings. README was already correct, so no red run; mutations of a number, boolean and null field in the README each turn it red (mutation-logs/15; green: redlogs/20-readme-scalars.green.log).

### Unreleased (review ffdeecd non-blocking 2)

- A first-page HTTP 400 on one SIREN or split sub-query no longer stops the whole run: the error is recorded in `OUTPUT.errors` with its URL and the remaining SIRENs / sub-queries are still fetched. The run fails (`invalid-filter`) only if it ends with 0 rows (red: redlogs/19-page1-400-continue.red.log; mutation: mutation-logs/14).

### Unreleased (review ffdeecd non-blocking 1)

- Tests only: new test for HTTP 400 on a later page => `api-cap`, SUCCEEDED with the page-1 rows; the old `0 rows + HTTP 400 api-cap` test is renamed to what it tests (page-1 400 => `invalid-filter`) and now asserts that stop reason. Behaviour was already correct, so there is no red run; mutation `page === 1` -> `page >= 1` turns 1 test red (mutation-logs/13; green: redlogs/18-later-page-400-api-cap.green.log).
- Correction to the QA 2f23c4c fix 2 entry: `invalidSirens` is an internal field computed by `normalizeInput()` (src/input.js), not an `input_schema` field or a dataset/OUTPUT field.

### Unreleased (QA 2f23c4c fix 4)

- Test coverage for the `finish()` safety net (0 rows + errors => failed, formerly main.js:114): extracted unchanged into exported `applyZeroRowsSafetyNet()`, called from `finish()`, with unit tests (red: redlogs/17-finish-safety-net.red.log; mutation: mutation-logs/11 removes the body => 1 red; mutation-logs/12 removes the call => 0 red, because no run() path reaches finish() with 0 rows + errors without failAndThrow).

### Unreleased (QA 2f23c4c fix 3)

- README: the first sample-row JSON now shows the real accented values (`société`, `pâtisserie fraîche`, `manufacturière`, `500 à 999 salariés`, `MARCQ-EN-BARŒUL`) exactly as the Actor outputs them; a test checks every string field against `transformCompany` on the fixture (QA 2f23c4c; red: redlogs/16-readme-accents.red.log).

### Unreleased (QA 2f23c4c fix 2)

- Malformed SIREN inputs (not exactly 9 digits, e.g. `"12345"`) are no longer silently padded and searched as no-results: they are skipped and named in a log warning and `OUTPUT.warnings`; with no valid SIREN left the run ends with `stopReason: "invalid-sirens"`, no search and no charge. Adds `invalidSirens` to the normalised input (QA 2f23c4c issue 2; red: redlogs/15-malformed-siren-warning.red.log; mutation: mutation-logs/10).

### Unreleased (QA 2f23c4c fix 1)

- An HTTP 400 on the first page of a query (invalid filter value, e.g. an unknown NAF code) now stops with `stopReason: "invalid-filter"` instead of `api-cap`, and the error names `HTTP 400`, the URL and the API message. A 400 on later pages keeps `api-cap` (QA 2f23c4c issue 1; red: redlogs/14-http400-invalid-filter.red.log; mutation: mutation-logs/09).

### Unreleased (review e9289d7 fix)

- A malformed or API-error 200 response (`{"erreur":...}`, missing `results`, invalid JSON) is always recorded in `OUTPUT.errors` with its URL, and with 0 rows the run FAILS on any page, including split sub-queries and later SIREN lookups; `finish()` also marks 0 rows + errors as failed as a safety net (review e9289d7 blocker 1).

### Unreleased (review 6a0a329 fixes)

- A run that ends with 0 rows and errors now FAILS (after writing OUTPUT), including a 5xx/429/403 after an auto-split and the HTTP 400 api-cap branch (review blocker 1).
- Multi-département input (e.g. `["75","13"]`) at the 10,000 cap is now split per département instead of stopping at 10,000; split helper no longer drops user postcodes when narrowing (review blocker 3 in the review / item 2 of the fix list).
- run()-level fixture tests for auto-split (no geo filter, multi-département), cross-département dedupe (not charged twice) and maxItems across split parts; mutation logs show disabling the split or the dedupe turns them red (review blocker 2).
- Wrap-up runs once: after a mid-run error the SIREN loop stops fetching and OUTPUT / status message / run-notice are written exactly once (review blocker 4).
- Mutation logs for the wrap-up fix: removing the SIREN-loop stop turns the test red; the idempotent `finish()` guard alone is defence in depth (mutation 03 survives by design).
- README: "Full output example" now shows a real company row with directors and establishments instead of the OUTPUT record; added a real 5-row sample table and an "Output fields" table; FAQ updated for the new failure rules (review blocker 5).
- Warning in `OUTPUT.warnings` (and the log) when a single postcode still has more than 10,000 results and is truncated (review non-blocking).
- Price set to $0.004 per company row in README and `pay_per_event.json` (review non-blocking).

### 0.1.0 (2026-11-01)

- First version: France Company Registry Scraper (`france-company-registry-scraper`) over the public Recherche d'entreprises API (`GET /search`, 25 results/page).
- Inputs: query, postal/departement/region filters, NAF, legal form, employee range, active-only, association flag, SIREN batch lookup, maxItems (default 100), optional directors and establishments, configurable rate limit (default 4 req/s).
- Output rows: flattened SIREN/SIRET, labels from bundled reference tables, computed FR VAT number, finances, complements, privacy stripping for sole traders and director birth dates.
- Auto-split by departement then postal code when `total_results >= 10000` and more items are requested.
- PPE event `result-row`; OUTPUT summary (`rowsPushed`, `pagesFetched`, `stopReason`, `robotsDisallowedHits`, `errors`) and `buildStatusMessage` / `setStatusMessage`.
- Stop paths: empty result SUCCEEDED with 0 charge; first-page 403/404/410/5xx with 0 rows FAILS after OUTPUT; later errors after rows SUCCEEDED with partial data.
- robots.txt 404 on the API host treated as no rules; Disallow matches warn + count only; Crawl-delay honoured when present.
- Docs: buyer README, ROBOTS.md, live smoke sample in `docs/live-sample.json`.
