WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@ayoubbts
Copy link

When max_tables is not specified in collect_schemas config, the default value is stored as float (300.0) instead of int. This causes a TypeError when used as a slice index in line 613.

What does this PR do?

Fixes a TypeError when collecting PostgreSQL schema metadata without explicitly specifying max_tables in the configuration. The PR converts the max_tables value to an integer before using it as a list slice index.

Motivation

When deploying the Datadog Agent with the Kubernetes Operator and enabling schema collection with only collect_schemas.enabled: true (without specifying max_tables), the agent fails with:
Error collecting schema metadata: slice indices must be integers or None or have an index method

Root cause: The max_tables config value is typed as Optional[float] and defaults to 300.0 (float). At line 613 in metadata.py, this float value is used as a slice index (table_info[:limit]), which Python rejects because slice indices must be integers.

Fix: Convert max_tables to int with fallback to default value at line 590:

limit = int(self._config.collect_schemas.max_tables)

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

When max_tables is not specified in collect_schemas config, the default
value is stored as float (300.0) instead of int. This causes a TypeError
when used as a slice index in line 613.
@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (7.72.x@0d5325a). Learn more about missing BASE report.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant