Skip to content

Conversation

@fatih-acar
Copy link
Contributor

@fatih-acar fatih-acar commented Nov 10, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Added infrahubctl task list command to view and filter tasks by state, limit, offset, and other criteria; supports table and JSON output formats.
  • Documentation

    • Added documentation for the new task CLI command group and available options.

@coderabbitai
Copy link

coderabbitai bot commented Nov 10, 2025

Walkthrough

A new task CLI command group is introduced to the infrahubctl tool. The implementation includes a list subcommand that displays tasks with filtering options by state, limit, and offset, and supports both table and JSON output formats. Documentation is added for the new command, and the CLI module is registered in the command structure. The task model's from_graphql method is updated to explicitly handle presence checks for related_nodes and logs fields. Unit tests validate the list command's behavior with various filtering and output scenarios.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The PR title 'Merge stable into develop' is generic and does not convey meaningful information about the specific changes being merged. Consider providing a more descriptive title that summarizes the key changes (e.g., 'Add infrahubctl task CLI command with list subcommand and documentation').
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fac-merge-stable-into-develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the type/documentation Improvements or additions to documentation label Nov 10, 2025
@cloudflare-workers-and-pages
Copy link

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: e3d2bff
Status: ✅  Deploy successful!
Preview URL: https://0259cebf.infrahub-sdk-python.pages.dev
Branch Preview URL: https://fac-merge-stable-into-develo.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 98.46154% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/task/models.py 83.33% 0 Missing and 1 partial ⚠️
@@             Coverage Diff             @@
##           develop     #610      +/-   ##
===========================================
+ Coverage    75.13%   75.57%   +0.43%     
===========================================
  Files          112      109       -3     
  Lines        10972     9384    -1588     
  Branches      2368     1869     -499     
===========================================
- Hits          8244     7092    -1152     
+ Misses        2138     1802     -336     
+ Partials       590      490     -100     
Flag Coverage Δ
integration-tests 34.82% <36.92%> (+<0.01%) ⬆️
python-3.10 48.81% <98.46%> (-1.63%) ⬇️
python-3.11 48.83% <98.46%> (-1.62%) ⬇️
python-3.12 48.81% <98.46%> (-1.63%) ⬇️
python-3.13 48.79% <98.46%> (-1.65%) ⬇️
python-3.9 47.53% <98.46%> (-1.47%) ⬇️
python-filler-3.12 24.28% <0.00%> (+0.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/cli_commands.py 71.08% <100.00%> (+0.35%) ⬆️
infrahub_sdk/ctl/task.py 100.00% <100.00%> (ø)
infrahub_sdk/task/models.py 98.27% <83.33%> (-1.73%) ⬇️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/docs/infrahubctl/infrahubctl-task.mdx (1)

33-33: Consider rephrasing for grammatical completeness.

While "Can be provided multiple times" is common in CLI documentation, it technically lacks a subject. Consider: "This option can be provided multiple times."

infrahub_sdk/ctl/task.py (1)

34-34: Pragma comment may be inaccurate.

The # pragma: no cover comment suggests this ValueError path won't be reached, but test_task_list_invalid_state in the test file does successfully exercise this error path by passing an invalid state value. The ValueError is raised, caught by Typer, converted to a BadParameter, and displayed to the user. Consider removing the pragma comment.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89426c6 and e3d2bff.

📒 Files selected for processing (6)
  • docs/docs/infrahubctl/infrahubctl-task.mdx (1 hunks)
  • docs/sidebars-infrahubctl.ts (1 hunks)
  • infrahub_sdk/ctl/cli_commands.py (2 hunks)
  • infrahub_sdk/ctl/task.py (1 hunks)
  • infrahub_sdk/task/models.py (1 hunks)
  • tests/unit/ctl/test_task_app.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method

Files:

  • infrahub_sdk/ctl/task.py
  • infrahub_sdk/ctl/cli_commands.py
  • infrahub_sdk/task/models.py
  • tests/unit/ctl/test_task_app.py
infrahub_sdk/ctl/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

infrahub_sdk/ctl/**/*.py: Build CLI commands with Typer
Organize and keep all CLI commands within infrahub_sdk/ctl/

Files:

  • infrahub_sdk/ctl/task.py
  • infrahub_sdk/ctl/cli_commands.py
docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (CLAUDE.md)

docs/**/*.{md,mdx}: Follow the Diataxis framework and classify docs as Tutorials, How-to guides, Explanation, or Reference
Structure How-to guides with required frontmatter and sections: introduction, prerequisites, step-by-step steps, validation, related resources
Structure Topics (Explanation) docs with introduction, concepts & definitions, background & context, architecture & design, connections, further reading
Use a professional, concise, informative tone with consistent structure across documents
Use proper language tags on all code blocks
Include both async and sync examples where applicable using the Tabs component
Add validation steps to guides to confirm success and expected outputs
Use callouts for warnings, tips, and important notes
Define new terms on first use and use domain-relevant terminology consistent with Infrahub’s model/UI
Conform to markdown style rules in .markdownlint.yaml and Vale styles in .vale/styles/

Files:

  • docs/docs/infrahubctl/infrahubctl-task.mdx
tests/unit/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Place and write unit tests under tests/unit/ (isolated component tests)

Files:

  • tests/unit/ctl/test_task_app.py
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use the custom pytest plugin (infrahub_sdk.pytest_plugin) fixtures for clients, configuration, and Infrahub-specific testing

Files:

  • tests/unit/ctl/test_task_app.py
🧠 Learnings (3)
📚 Learning: 2025-08-24T13:35:12.998Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T13:35:12.998Z
Learning: Applies to infrahub_sdk/ctl/**/*.py : Build CLI commands with Typer

Applied to files:

  • infrahub_sdk/ctl/task.py
  • infrahub_sdk/ctl/cli_commands.py
  • docs/sidebars-infrahubctl.ts
  • tests/unit/ctl/test_task_app.py
📚 Learning: 2025-08-24T13:35:12.998Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T13:35:12.998Z
Learning: Applies to infrahub_sdk/ctl/**/*.py : Organize and keep all CLI commands within infrahub_sdk/ctl/

Applied to files:

  • infrahub_sdk/ctl/task.py
  • infrahub_sdk/ctl/cli_commands.py
  • docs/sidebars-infrahubctl.ts
📚 Learning: 2025-08-24T13:35:12.998Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T13:35:12.998Z
Learning: Applies to infrahub_sdk/config.py : Environment variables for configuration must use the INFRAHUB_ prefix

Applied to files:

  • docs/sidebars-infrahubctl.ts
🧬 Code graph analysis (2)
infrahub_sdk/ctl/task.py (4)
infrahub_sdk/async_typer.py (2)
  • AsyncTyper (11-31)
  • command (29-31)
infrahub_sdk/task/models.py (3)
  • TaskFilter (65-76)
  • Task (32-62)
  • TaskState (9-18)
infrahub_sdk/ctl/client.py (1)
  • initialize_client (10-25)
infrahub_sdk/ctl/utils.py (2)
  • catch_exception (78-106)
  • init_logging (42-50)
tests/unit/ctl/test_task_app.py (1)
infrahub_sdk/async_typer.py (1)
  • runner (17-18)
🪛 LanguageTool
docs/docs/infrahubctl/infrahubctl-task.mdx

[style] ~33-~33: To form a complete sentence, be sure to include a subject.
Context: ...s, --state TEXT: Filter by task state. Can be provided multiple times. * --limit ...

(MISSING_IT_THERE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (10)
infrahub_sdk/task/models.py (1)

52-60: LGTM: Explicit key-presence checks improve robustness.

The updated logic now ensures related_nodes and logs keys are deleted from the input data whenever they are present, even if their values are falsy (empty list, None, etc.). This is more defensive than relying solely on data.get() truthiness and prevents potential issues with downstream code that might not expect these keys to remain.

docs/sidebars-infrahubctl.ts (1)

27-27: LGTM: Sidebar entry correctly added.

The new documentation entry for the task CLI is properly positioned alphabetically within the Commands category.

infrahub_sdk/ctl/cli_commands.py (2)

36-36: LGTM: Task CLI module imported correctly.

The import follows the established pattern for other CLI modules in this file.


69-69: LGTM: Task CLI group registered properly.

The registration follows the same pattern as other command groups (branch, schema, validate, etc.) and correctly exposes the task commands under the infrahubctl task namespace.

tests/unit/ctl/test_task_app.py (2)

20-44: LGTM: Well-structured test helper.

The _task_response() helper provides a realistic mock GraphQL response structure with all necessary fields for testing the task list functionality.


51-100: LGTM: Comprehensive test coverage for task list command.

The test suite covers the key scenarios:

  • Basic table rendering with task data
  • JSON output format and content validation
  • State filtering with empty results
  • Error handling for invalid state values

This provides solid baseline coverage for the new CLI functionality.

infrahub_sdk/ctl/task.py (4)

20-22: LGTM: Command group callback properly defined.

The callback provides the appropriate description for the task command group.


25-39: LGTM: State parsing with proper validation.

The _parse_states helper correctly normalizes input strings and converts them to TaskState enum values, with clear error messages for invalid states using Typer's BadParameter exception.


42-69: LGTM: Table rendering with proper formatting and empty-state handling.

The _render_table helper creates a well-structured Rich table with appropriate column styling and gracefully handles the empty tasks case.


72-110: LGTM: Comprehensive task listing command.

The list_tasks command provides:

  • Multiple filtering options (state, limit, offset)
  • Optional inclusion of related nodes and logs
  • Both table and JSON output formats
  • Proper async implementation with AsyncTyper
  • Error handling via catch_exception decorator

The implementation follows established CLI patterns and coding guidelines.

Based on learnings

@fatih-acar fatih-acar merged commit e37672c into develop Nov 10, 2025
34 of 35 checks passed
@fatih-acar fatih-acar deleted the fac-merge-stable-into-develop branch November 10, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants