Skip to content

Fix: create_config TypeError when read_timeout is passed via config#368

Open
evanerwee wants to merge 1 commit into
awslabs:mainfrom
evanerwee:fix/create-config-read-timeout
Open

Fix: create_config TypeError when read_timeout is passed via config#368
evanerwee wants to merge 1 commit into
awslabs:mainfrom
evanerwee:fix/create-config-read-timeout

Conversation

@evanerwee

Copy link
Copy Markdown
Contributor

Fixes #361.

Problem

create_config() hardcodes read_timeout=600 as a keyword argument AND spreads user config via **config_args. When a user passes read_timeout in their config JSON, Python raises:

TypeError: botocore.config.Config() got multiple values for keyword argument 'read_timeout'

Same issue affects retries and user_agent_appid.

Fix

Use setdefault() for all hardcoded values — the same pattern already used for max_pool_connections on the line immediately above. User-provided values take precedence; defaults apply when absent.

# Before (breaks):
return Config(read_timeout=600, **config_args)  # duplicate kwarg

# After (works):
config_args.setdefault('read_timeout', 600)
return Config(**config_args)                     # no conflict

Impact

  • 4-line change, no new logic
  • All existing defaults preserved (non-breaking)
  • Users can now configure read_timeout, retries, and user_agent_appid
  • Critical for production deployments behind API Gateway / ALB / Lambda timeouts

When a user passes read_timeout (or retries, user_agent_appid) via the
config JSON string, Config() receives duplicate keyword arguments and
raises TypeError.

The fix uses setdefault() for all hardcoded values — the same pattern
already used for max_pool_connections on the line immediately above.
User-provided values take precedence; defaults apply when absent.

Fixes awslabs#361
@mykola-pereyma

Copy link
Copy Markdown
Collaborator

Thanks, we will review you PR shortly.

@mykola-pereyma mykola-pereyma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix — the setdefault approach is clean and correct. Asking for regression tests before merge since this is a bug fix and best practice is to have a test that would have caught the original issue.

config_args.setdefault('read_timeout', 600)
config_args.setdefault('retries', {'total_max_attempts': 1, 'mode': 'standard'})
config_args.setdefault('user_agent_appid', f'graphrag-lexical-graph-{toolkit_version}')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks correct and follows same pattern already used for max_pool_connections above. Could you add regression tests for the three fields that were breaking? The existing TestCreateConfig class in test_neptune_graph_stores.py already has this pattern for max_pool_connections so should be straightforward. Without regression tests there is nothing preventing someone from refactoring this back to kwargs and reintroducing the TypeError.

@marora90

Copy link
Copy Markdown

Thanks for opening this @evanerwee I’d like to help get this over the line. Since the requested changes have been waiting for a couple weeks, I’m going to open a follow-up PR that cherry-picks your commits and addresses the review feedback. Happy to close mine if you’d prefer to continue this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Neptune create_config raises TypeError when read_timeout is passed

3 participants