@@ -1097,38 +1097,30 @@ def prompt_for_identity(
1097
1097
identity_fields = {}
1098
1098
1099
1099
fields = [
1100
- ("name" , "[blue]Display name[/blue]" , name ),
1101
- ("url" , "[blue]Web URL[/blue]" , web_url ),
1102
- ("image" , "[blue]Image URL[/blue]" , image_url ),
1103
- ("discord" , "[blue]Discord handle[/blue]" , discord ),
1104
- ("description" , "[blue]Description[/blue]" , description ),
1105
- ("additional" , "[blue]Additional information[/blue]" , additional ),
1106
- ("github_repo" , "[blue]GitHub repository URL[/blue]" , github_repo ),
1100
+ ("name" , "[blue]Display name[/blue]" , name , 256 ),
1101
+ ("url" , "[blue]Web URL[/blue]" , web_url , 256 ),
1102
+ ("image" , "[blue]Image URL[/blue]" , image_url , 1024 ),
1103
+ ("discord" , "[blue]Discord handle[/blue]" , discord , 256 ),
1104
+ ("description" , "[blue]Description[/blue]" , description , 1024 ),
1105
+ ("additional" , "[blue]Additional information[/blue]" , additional , 1024 ),
1106
+ ("github_repo" , "[blue]GitHub repository URL[/blue]" , github_repo , 256 ),
1107
1107
]
1108
1108
1109
- text_rejection = partial (
1110
- retry_prompt ,
1111
- rejection = lambda x : sys .getsizeof (x ) > 113 ,
1112
- rejection_text = "[red]Error:[/red] Identity field must be <= 64 raw bytes." ,
1113
- )
1114
-
1115
1109
if not any (
1116
- [
1117
- name ,
1118
- web_url ,
1119
- image_url ,
1120
- discord ,
1121
- description ,
1122
- additional ,
1123
- github_repo ,
1124
- ]
1110
+ [name , web_url , image_url , discord , description , additional , github_repo ]
1125
1111
):
1126
1112
console .print (
1127
1113
"\n [yellow]All fields are optional. Press Enter to skip and keep the default/existing value.[/yellow]\n "
1128
1114
"[dark_sea_green3]Tip: Entering a space and pressing Enter will clear existing default value.\n "
1129
1115
)
1130
1116
1131
- for key , prompt , value in fields :
1117
+ for key , prompt , value , byte_limit in fields :
1118
+ text_rejection = partial (
1119
+ retry_prompt ,
1120
+ rejection = lambda x : len (x .encode ("utf-8" )) > byte_limit ,
1121
+ rejection_text = f"[red]Error:[/red] { key } field must be <= { byte_limit } bytes." ,
1122
+ )
1123
+
1132
1124
if value :
1133
1125
identity_fields [key ] = value
1134
1126
else :
@@ -1170,50 +1162,51 @@ def prompt_for_subnet_identity(
1170
1162
"subnet_name" ,
1171
1163
"[blue]Subnet name [dim](optional)[/blue]" ,
1172
1164
subnet_name ,
1173
- lambda x : x and sys . getsizeof ( x ) > 113 ,
1174
- "[red]Error:[/red] Subnet name must be <= 64 raw bytes." ,
1165
+ lambda x : x and len ( x . encode ( "utf-8" )) > 256 ,
1166
+ "[red]Error:[/red] Subnet name must be <= 256 bytes." ,
1175
1167
),
1176
1168
(
1177
1169
"github_repo" ,
1178
1170
"[blue]GitHub repository URL [dim](optional)[/blue]" ,
1179
1171
github_repo ,
1180
- lambda x : x and not is_valid_github_url (x ),
1172
+ lambda x : x
1173
+ and (not is_valid_github_url (x ) or len (x .encode ("utf-8" )) > 1024 ),
1181
1174
"[red]Error:[/red] Please enter a valid GitHub repository URL (e.g., https://github.com/username/repo)." ,
1182
1175
),
1183
1176
(
1184
1177
"subnet_contact" ,
1185
1178
"[blue]Contact email [dim](optional)[/blue]" ,
1186
1179
subnet_contact ,
1187
- lambda x : x and not is_valid_contact (x ),
1180
+ lambda x : x and ( not is_valid_contact (x ) or len ( x . encode ( "utf-8" )) > 1024 ),
1188
1181
"[red]Error:[/red] Please enter a valid email address." ,
1189
1182
),
1190
1183
(
1191
1184
"subnet_url" ,
1192
1185
"[blue]Subnet URL [dim](optional)[/blue]" ,
1193
1186
subnet_url ,
1194
- lambda x : x and sys . getsizeof ( x ) > 113 ,
1195
- "[red]Error:[/red] Please enter a valid URL." ,
1187
+ lambda x : x and len ( x . encode ( "utf-8" )) > 1024 ,
1188
+ "[red]Error:[/red] Please enter a valid URL <= 1024 bytes ." ,
1196
1189
),
1197
1190
(
1198
1191
"discord" ,
1199
1192
"[blue]Discord handle [dim](optional)[/blue]" ,
1200
1193
discord ,
1201
- lambda x : x and sys . getsizeof ( x ) > 113 ,
1202
- "[red]Error:[/red] Please enter a valid Discord handle." ,
1194
+ lambda x : x and len ( x . encode ( "utf-8" )) > 256 ,
1195
+ "[red]Error:[/red] Please enter a valid Discord handle <= 256 bytes ." ,
1203
1196
),
1204
1197
(
1205
1198
"description" ,
1206
1199
"[blue]Description [dim](optional)[/blue]" ,
1207
1200
description ,
1208
- lambda x : x and sys . getsizeof ( x ) > 113 ,
1209
- "[red]Error:[/red] Description must be <= 64 raw bytes." ,
1201
+ lambda x : x and len ( x . encode ( "utf-8" )) > 1024 ,
1202
+ "[red]Error:[/red] Description must be <= 1024 bytes." ,
1210
1203
),
1211
1204
(
1212
1205
"additional" ,
1213
1206
"[blue]Additional information [dim](optional)[/blue]" ,
1214
1207
additional ,
1215
- lambda x : x and sys . getsizeof ( x ) > 113 ,
1216
- "[red]Error:[/red] Additional information must be <= 64 raw bytes." ,
1208
+ lambda x : x and len ( x . encode ( "utf-8" )) > 1024 ,
1209
+ "[red]Error:[/red] Additional information must be <= 1024 bytes." ,
1217
1210
),
1218
1211
]
1219
1212
0 commit comments