How to Fix MySQL Error 3672 (ER_INVALID_GEOJSON_CRS_NOT_TOP_LEVEL)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mysql error 3672 when a GeoJSON string puts the crs member inside a child object. To fix this error, move the crs member up to the root level of your GeoJSON document. This failure uses the official symbol ER_INVALID_GEOJSON_CRS_NOT_TOP_LEVEL and returns the general SQLSTATE code HY000. MySQL stops the spatial query right away because the input breaks strict GeoJSON parsing rules. Your app cannot save or read the map data until you fix the JSON layout. What causes mysql error 3672 in

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You get mysql error 3672 when a GeoJSON string puts the crs member inside a child object. To fix this error, move the crs member up to the root level of your GeoJSON document.

This failure uses the official symbol ER_INVALID_GEOJSON_CRS_NOT_TOP_LEVEL and returns the general SQLSTATE code HY000. MySQL stops the spatial query right away because the input breaks strict GeoJSON parsing rules. Your app cannot save or read the map data until you fix the JSON layout.

What causes mysql error 3672 in spatial queries

MySQL spatial functions read GeoJSON text and turn it into internal geometry values. When you run these functions, the database checks the structure of your JSON payload. The engine prints a clear message stating that the crs member must sit in the top object.

In GeoJSON, the crs field defines the coordinate reference system for your map shapes. A document can hold one single point, a list of shapes, or a collection of features. When an app builds a feature collection, it often merges many small map shapes together.

If each small shape brings its own crs key, those keys end up nested inside the array. MySQL reads the outer object first and then checks the inner geometry items. When the parser finds a crs key inside a child item, it halts and throws error 3672.

This bug often happens when you pull spatial data from external map APIs. Third-party tools might tag every single shape with a coordinate system before sending the batch. Data pipelines that merge GeoJSON files without cleaning child fields will also trigger this database failure.

How to find and fix nested CRS fields in production

To fix this issue, you must inspect the raw JSON payload before it hits the database. Start by checking your app logs to find the exact spatial query that failed. Do not grant full database admin rights to developers just to debug these bad payloads.

Instead, read the failed input from your app error logs or dead-letter queues. Look at the JSON tree and search for every place where the crs key appears. You will find it sitting inside a geometry array or a nested feature object.

MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Update your app code so it strips the crs field from all inner child objects. Next, place one single crs definition at the very top root level of the JSON document. Make sure all shapes in that group use the exact same coordinate system before merging them.

If the child shapes use different coordinate systems, do not group them into one GeoJSON object. Split them into separate database rows or convert their coordinates in your app first. You can also add a schema check in your API to block nested crs keys early.

How to prevent GeoJSON parsing failures across teams

Fixing one broken query is easy, but keeping production data clean takes good team habits. Many teams run manual fix scripts on live databases when a data pipeline breaks. Running ad-hoc spatial updates in production carries high risk and can corrupt valid map rows.

Set up a staging step where your app checks all incoming GeoJSON before writing to MySQL. If a partner API sends bad data, catch it in your worker queue and alert the team. When engineers need to check live data, use safe read roles that protect sensitive columns.

For example, data masking can rewrite emails, phone numbers, card numbers, or national IDs in query results. This lets your team inspect broken spatial rows while keeping private user details safe. Good validation in your app code stops bad GeoJSON from ever reaching your database engine.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.

With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

What does ER_INVALID_GEOJSON_CRS_NOT_TOP_LEVEL mean in MySQL?

This symbol means your GeoJSON string has a crs field inside a nested child object. MySQL requires the coordinate system definition to sit at the root of the JSON document.

Can I turn off the CRS check in MySQL to bypass error 3672?

No, MySQL enforces this rule inside its built-in GeoJSON parser and you cannot disable it. You must clean the JSON payload in your app before sending it to the database.

What if my nested shapes use different coordinate systems?

You cannot mix different coordinate systems inside one single GeoJSON object in MySQL. Convert all shapes to match one system in your app, or save them as separate rows.

The query runs. The emails stay hidden.