Skip to content

Commit 9969960

Browse files
authored
fix: Increase ACTOR_ENUM_MAX_LENGTH from 200 to 2000 to ensure that geocode are not removed (#292)
* fix: Increase ACTOR_ENUM_MAX_LENGTH from 200 to 2000 to ensure that geocode are not removed
1 parent 834e381 commit 9969960

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/const.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Actor input const
22
export const ACTOR_README_MAX_LENGTH = 5_000;
3-
export const ACTOR_ENUM_MAX_LENGTH = 200;
3+
// Actor enum property max length, we need to make sure that most of the enum values fit into the input (such as geocodes)
4+
export const ACTOR_ENUM_MAX_LENGTH = 2000;
45
export const ACTOR_MAX_DESCRIPTION_LENGTH = 500;
56

6-
export const ACTOR_RUN_DATASET_OUTPUT_MAX_ITEMS = 5;
7-
87
// Actor run const
98
export const ACTOR_MAX_MEMORY_MBYTES = 4_096; // If the Actor requires 8GB of memory, free users can't run actors-mcp-server and requested Actor
109

src/tools/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ export function shortenEnum(enumList: string[]): string[] | undefined {
278278

279279
/**
280280
* Shortens the description, enum, and items.enum properties of the schema properties.
281+
* This is mostly problem with compass/crawler-google-places, which has large number of categories
282+
* such as ( 'abbey', 'accountant', 'accounting', 'acupuncturist', .... )
281283
* @param properties
282284
*/
283285
export function shortenProperties(properties: { [key: string]: ISchemaProperties }): {

tests/unit/tools.utils.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ describe('shortenProperties', () => {
356356

357357
it('should shorten enum values if they exceed the limit', () => {
358358
// Create an enum with many values to exceed the character limit
359-
const enumValues = Array.from({ length: 50 }, (_, i) => `enum-value-${i}`);
359+
const value = 'enum-value-';
360+
const enumValues = Array.from({ length: Math.ceil(ACTOR_ENUM_MAX_LENGTH / value.length) + 1 }, (_, i) => `${value}${i}`);
360361
const properties: Record<string, ISchemaProperties> = {
361362
prop1: {
362363
type: 'string',
@@ -371,7 +372,7 @@ describe('shortenProperties', () => {
371372
// Check that enum was shortened
372373
expect(result.prop1.enum).toBeDefined();
373374
if (result.prop1.enum) {
374-
expect(result.prop1.enum.length).toBeLessThan(30);
375+
expect(result.prop1.enum.length).toBeLessThan(enumValues.length);
375376
const totalEnumLen = result.prop1.enum.reduce((sum, v) => sum + v.length, 0);
376377
expect(totalEnumLen).toBeLessThanOrEqual(ACTOR_ENUM_MAX_LENGTH);
377378

@@ -385,7 +386,8 @@ describe('shortenProperties', () => {
385386

386387
it('should shorten items.enum values if they exceed the limit', () => {
387388
// Create an enum with many values to exceed the character limit
388-
const enumValues = Array.from({ length: 50 }, (_, i) => `enum-value-${i}`);
389+
const value = 'enum-value-';
390+
const enumValues = Array.from({ length: Math.ceil(ACTOR_ENUM_MAX_LENGTH / value.length) + 1 }, (_, i) => `${value}${i}`);
389391
const properties: Record<string, ISchemaProperties> = {
390392
prop1: {
391393
type: 'array',
@@ -889,8 +891,8 @@ describe('inferArrayItemsTypeIfMissing', () => {
889891
describe('shortenEnum', () => {
890892
it('shorten enum list', () => {
891893
const enumList: string[] = [];
892-
const wordLength = 10;
893-
const wordCount = 30;
894+
const wordLength = 100;
895+
const wordCount = ACTOR_ENUM_MAX_LENGTH / wordLength + 1; // exceed the limit
894896

895897
for (let i = 0; i < wordCount; i++) {
896898
enumList.push('a'.repeat(wordLength));

0 commit comments

Comments
 (0)