Naturalization of names resulting in >100 characters causes shcema migration to fail #3326

Closed
opened 2025-12-29 18:27:44 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Feb 14, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.6.9
  • NetBox version: 2.7.5

Steps to Reproduce

  1. Start with a v2.7.4 installation
  2. Create a site named "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a"
  3. Upgrade to v2.7.5 and run apply database schema migrations

Expected Behavior

All migrations should complete successfully.

Observed Behavior

The migration 0095_primary_model_ordering fails with the following error:

django.db.utils.DataError: value too long for type character varying(100)

This happens because the name "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a" expands to a string greater than 100 characters in length, which is the maximum length for the database field. The naturalization function accepts an argument to cut the naturalized string to a specific length, however the parameter is not being passed by the migration function.

It should be noted that this can be reproduced with any model using naturalized ordering if the source name is constructed in such a way that its naturalized version exceeds 100 characters.

Originally created by @jeremystretch on GitHub (Feb 14, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.6.9 * NetBox version: 2.7.5 ### Steps to Reproduce 1. Start with a v2.7.4 installation 2. Create a site named "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a" 3. Upgrade to v2.7.5 and run apply database schema migrations ### Expected Behavior All migrations should complete successfully. ### Observed Behavior The migration `0095_primary_model_ordering` fails with the following error: ``` django.db.utils.DataError: value too long for type character varying(100) ``` This happens because the name "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a" expands to a string greater than 100 characters in length, which is the maximum length for the database field. The naturalization function accepts an argument to cut the naturalized string to a specific length, however the parameter is not being passed by the migration function. It should be noted that this can be reproduced with any model using naturalized ordering if the source name is constructed in such a way that its naturalized version exceeds 100 characters.
adam added the type: bugstatus: accepted labels 2025-12-29 18:27:44 +01:00
adam closed this issue 2025-12-29 18:27:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3326