Skip to content

Conversation

@JarJak
Copy link
Contributor

@JarJak JarJak commented Jan 2, 2026

Fixes error:
Cannot assign null to property GeoIp2\Model\City::$mostSpecificSubdivision of type GeoIp2\Record\Subdivision

Which happens for example for IP from Hongkong.

Fixes error:
```Cannot assign null to property GeoIp2\Model\City::$mostSpecificSubdivision of type GeoIp2\Record\Subdivision```

Which happens for example for IP from Hongkong.
@horgh
Copy link
Contributor

horgh commented Jan 2, 2026

In which database did you see this? It seems unexpected to have records that would hit this.

@JarJak
Copy link
Contributor Author

JarJak commented Jan 5, 2026

It is on GeoIP City Database

@horgh
Copy link
Contributor

horgh commented Jan 5, 2026

I see. Is it a database from MaxMind? Do you know what the date of the database is?

You could use the mmdbinspect tool to get this information: https://github.com/maxmind/mmdbinspect

Run it like: ./mmdbinspect -db /path/to/GeoIP2-City.mmdb -include-build-time 1.2.3.4 (replace 1.2.3.4 with an IP)

Would you be able to share the output from that please? And the filename you run it on?

Thank you for your patience and help! I am not opposed to merging the change, but I'm hoping to understand if there's an issue with the database itself. So far I have not been able to see any empty subdivisions myself.

@JarJak
Copy link
Contributor Author

JarJak commented Jan 7, 2026

Here is the output of the inspect tool for these example problematic IPs:

  1. Cayman Islands
database_path: /geoip/GeoIP2-City.mmdb
build_time: 2025-10-15T07:08:38Z
requested_lookup: 95.214.112.9
network: 95.214.112.0/24
record:
  city:
    names:
      en: George Town
  continent: {}
  country:
    iso_code: KY
    names:
      en: Cayman Islands
  location:
    latitude: 19.3
    longitude: -81.3833333
  postal:
    code: KY1-1000
  registered_country: {}
  subdivisions: []
  1. Hong Kong
database_path: /geoip/GeoIP2-City.mmdb
build_time: 2025-10-15T07:08:38Z
requested_lookup: 192.166.244.111
network: 192.166.244.0/24
record:
  city:
    names:
      en: Hong Kong
  continent: {}
  country:
    iso_code: HK
    names:
      en: Hong Kong
  location:
    latitude: 22.2833333
    longitude: 114.15
  postal:
    code: D08
  registered_country: {}
  subdivisions: []
  1. Monaco
database_path: /geoip/GeoIP2-City.mmdb
build_time: 2025-10-15T07:08:38Z
requested_lookup: 82.149.81.108
network: 82.149.81.0/24
record:
  city:
    names:
      en: Monte Carlo
  continent: {}
  country:
    iso_code: MC
    names:
      en: Monaco
  location:
    latitude: 43.739722
    longitude: 7.427222
  postal:
    code: "98000"
  registered_country: {}
  subdivisions: []

@horgh
Copy link
Contributor

horgh commented Jan 7, 2026

Thank you! So it looks like that database isn't one from MaxMind.

We can merge this change, but it would also be good if you could ask the provider to see if they could update their databases to omit empty subdivisions if they're expecting people to use this library with it.

@horgh horgh merged commit 6f9a6aa into maxmind:main Jan 7, 2026
18 checks passed
horgh added a commit that referenced this pull request Jan 7, 2026
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
oschwald added a commit that referenced this pull request Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants