Skip to content

EDM-4975: Fix inventory env var fallback, OIDC-based username/password auth, and lazy jsonschema/PyYAML loading in ConfigLoader - #59

Open
SiddarthR56 wants to merge 2 commits into
flightctl:mainfrom
SiddarthR56:fac-1.2
Open

EDM-4975: Fix inventory env var fallback, OIDC-based username/password auth, and lazy jsonschema/PyYAML loading in ConfigLoader#59
SiddarthR56 wants to merge 2 commits into
flightctl:mainfrom
SiddarthR56:fac-1.2

Conversation

@SiddarthR56

@SiddarthR56 SiddarthR56 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Updated authentication in plugins/inventory/, plugins/module_utils/, and shared OIDC utilities.
  • Username/password credentials now use OIDC password-grant authentication and Bearer tokens.
  • Added OIDC discovery and token-exchange helpers with TLS, CA, timeout, and error handling.
  • Cached inventory tokens and cleared stored credentials after successful authentication.
  • Deferred jsonschema and PyYAML checks until ConfigLoader loads a configuration file.
  • Expanded galaxy.yml build_ignore patterns for CI files, tooling, changelogs, archives, and hidden files.

Tests

  • Added OIDC tests for discovery, token fallback, credential errors, transport failures, and invalid responses.
  • Updated inventory, API module, and Image Builder authentication tests.
  • Added ConfigLoader tests for deferred dependencies, YAML parsing, and missing files.

API and compatibility

  • No argument-spec or return-value changes are reported.
  • Added public OIDC helper methods in plugins/module_utils/oidc_auth.py.
  • Username/password authentication no longer sends HTTP Basic credentials.
  • Username/password authentication now requires a valid OIDC provider and token endpoint.
  • Direct Bearer-token and unauthenticated behavior remain unchanged.
  • Missing jsonschema or PyYAML no longer affects configurations that do not load a configuration file.
  • Existing deployments that rely on Basic authentication must provide compatible OIDC configuration. Otherwise, authentication fails instead of silently using Basic credentials.

…d auth, and lazy jsonschema/PyYAML loading in ConfigLoader

Assisted-by: Cursor/Claude
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 424aec13-84dc-4c3a-8015-a59be30e561a

📥 Commits

Reviewing files that changed from the base of the PR and between 12426cd and 689c6d2.

📒 Files selected for processing (8)
  • plugins/inventory/flightctl.py
  • plugins/module_utils/api_module.py
  • plugins/module_utils/imagebuilder_module.py
  • plugins/module_utils/oidc_auth.py
  • tests/unit/plugins/inventory/test_flightctl.py
  • tests/unit/plugins/module_utils/test_api_module.py
  • tests/unit/plugins/module_utils/test_imagebuilder_module.py
  • tests/unit/plugins/module_utils/test_oidc_auth.py

Walkthrough

Changes

OIDC authentication

Layer / File(s) Summary
OIDC discovery and password grant
plugins/module_utils/oidc_auth.py, tests/unit/plugins/module_utils/test_oidc_auth.py
Added OIDC provider discovery and password-grant helpers. Tests cover token selection and error handling.
Consumer bearer authentication
plugins/inventory/flightctl.py, plugins/module_utils/api_module.py, plugins/module_utils/imagebuilder_module.py
Replaced username/password Basic authentication with bearer-token authentication. FlightCtl caches the token.
Consumer authentication validation
tests/unit/plugins/inventory/test_flightctl.py, tests/unit/plugins/module_utils/test_api_module.py, tests/unit/plugins/module_utils/test_imagebuilder_module.py
Tests cover token caching, parameter forwarding, bearer headers, direct tokens, unauthenticated configurations, and grant failures.

Configuration and packaging

Layer / File(s) Summary
Deferred configuration dependencies
plugins/module_utils/config_loader.py, tests/unit/plugins/module_utils/test_config_loader.py
Dependency checks now run only when a configuration file is loaded. Tests cover parsing and missing files.
Expanded build exclusions
galaxy.yml
Added exclusions for CI, integration, tooling, changelogs, archives, and hidden files or directories.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant oidc_password_grant
  participant AuthConfig
  participant OIDCProvider
  Consumer->>oidc_password_grant: provide credentials and connection settings
  oidc_password_grant->>AuthConfig: request authentication configuration
  AuthConfig-->>oidc_password_grant: return OIDC provider
  oidc_password_grant->>OIDCProvider: discover token endpoint
  OIDCProvider-->>oidc_password_grant: return endpoint and client ID
  oidc_password_grant->>OIDCProvider: submit password grant
  OIDCProvider-->>oidc_password_grant: return bearer token
  oidc_password_grant-->>Consumer: set bearer authorization
Loading

Suggested labels: collection-metadata, plugins, module-utils, tests

Suggested reviewers: efratifergan


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error High risk: raw OIDC error details flow into fail_json and ValidationException, so Ansible output can expose sensitive data returned by the authentication server. Return a generic authentication error or redact endpoint, exception, and error_description content before fail_json or raising exceptions.
Docstring Coverage ⚠️ Warning Docstring coverage is 41.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: inventory environment variables, OIDC authentication, and lazy dependency loading.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Hardcoded-Secrets ✅ Passed No production file contains a hardcoded credential, private key, or credential-bearing URL; added credential literals are isolated dummy unit-test fixtures.
No-Weak-Crypto ✅ Passed The full PR diff adds no MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB, or custom crypto; production token handling has no secret equality checks.
No-Injection-Vectors ✅ Passed AST and textual scans found no shell=True, eval/exec, pickle.loads, or os.system; the only yaml.load uses Loader=yaml.SafeLoader.
Ansible-Idempotency ✅ Passed The PR changes authentication, config loading, and packaging only; no create/update/delete or command tasks changed. Existing modules inherit check-mode support.
Ai-Attribution ✅ Passed Both PR commits use the accepted Assisted-by: Cursor/Claude trailer, and neither uses Co-Authored-By.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/inventory/flightctl.py`:
- Around line 487-491: Clear retained username and password immediately after
successful bearer-token caching in flightctl.py#487-491, api_module.py#183-195,
and imagebuilder_module.py#80-92, while preserving the bearer-header behavior.
Update the corresponding success-path tests in
tests/unit/plugins/inventory/test_flightctl.py#599-615,
tests/unit/plugins/module_utils/test_api_module.py#155-177, and
tests/unit/plugins/module_utils/test_imagebuilder_module.py#48-71 to assert both
credentials are cleared.
- Around line 475-482: Update _setup_connection_configuration so an omitted
verify_ssl option defaults to True and preserves False only when explicitly
configured, allowing _build_auth_headers to pass certificate validation to
oidc_password_grant. Add coverage for the omitted-option case and verify the
resulting Configuration value remains True.

In `@plugins/module_utils/api_module.py`:
- Around line 191-195: Prevent construction from continuing after OIDC
password-grant authentication fails: in plugins/module_utils/api_module.py lines
191-195 and plugins/module_utils/imagebuilder_module.py lines 88-92, raise
FlightctlException after fail_json returns without a bearer token so
Authorization is never set to Bearer None. Add coverage for non-raising
error_callback behavior in tests/unit/plugins/module_utils/test_api_module.py
lines 180-194 and tests/unit/plugins/module_utils/test_imagebuilder_module.py
lines 73-91, asserting FlightctlException is raised.

In `@plugins/module_utils/oidc_auth.py`:
- Around line 29-31: Fix the Flake8 E127 continuation indentation at
plugins/module_utils/oidc_auth.py:29-31 by reindenting the open_url call or
using parentheses; apply the same correction to the HTTPError continuations at
tests/unit/plugins/module_utils/test_oidc_auth.py:165-168 and
tests/unit/plugins/inventory/test_flightctl.py:620-622, and to the multi-context
with statement at
tests/unit/plugins/module_utils/test_imagebuilder_module.py:81-87. Preserve the
existing behavior while making all listed sites lint-clean.
- Around line 29-32: Validate all trust-boundary data before
oidc_password_grant() sends credentials: ensure http_get_json() returns a JSON
object, validate auth_config/provider/spec and token_data object shapes and
required string fields, and require discovery issuer/token_endpoint URLs to be
allowed HTTPS URLs matching the configured issuer where applicable. Perform
these checks before constructing or posting the password grant, rejecting
malformed, HTTP, or mismatched values.

In `@tests/unit/plugins/module_utils/test_config_loader.py`:
- Around line 31-73: Update the ConfigLoader tests in TestConfigLoaderParsing
and the dependency-error tests to mock filesystem access instead of creating
files with tmp_path. Patch the open operation used by ConfigLoader to return the
required YAML content for successful and dependency-error cases, and raise
FileNotFoundError for the missing-file case; preserve the existing assertions
and exception expectations.

In `@tests/unit/plugins/module_utils/test_oidc_auth.py`:
- Around line 13-17: New test helpers and test functions lack required type
annotations. In tests/unit/plugins/module_utils/test_oidc_auth.py lines 13-17
and 41-208, tests/unit/plugins/inventory/test_flightctl.py lines 535-539 and
563-650, tests/unit/plugins/module_utils/test_api_module.py lines 136-194, and
tests/unit/plugins/module_utils/test_imagebuilder_module.py lines 26-91,
annotate helper parameters and add -> None to every new test function or method,
using appropriate existing types for helper inputs and preserving test behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c52b7762-390e-4710-8d3e-90a0150d82ea

📥 Commits

Reviewing files that changed from the base of the PR and between 6b15b4c and 12426cd.

📒 Files selected for processing (11)
  • galaxy.yml
  • plugins/inventory/flightctl.py
  • plugins/module_utils/api_module.py
  • plugins/module_utils/config_loader.py
  • plugins/module_utils/imagebuilder_module.py
  • plugins/module_utils/oidc_auth.py
  • tests/unit/plugins/inventory/test_flightctl.py
  • tests/unit/plugins/module_utils/test_api_module.py
  • tests/unit/plugins/module_utils/test_config_loader.py
  • tests/unit/plugins/module_utils/test_imagebuilder_module.py
  • tests/unit/plugins/module_utils/test_oidc_auth.py

Comment on lines +475 to +482
bearer_token, error_detail = oidc_password_grant(
host=getattr(config, 'host', None),
username=username,
password=password,
verify_ssl=getattr(config, 'verify_ssl', True),
ca_path=getattr(config, 'ssl_ca_cert', None),
request_timeout=getattr(config, 'request_timeout', None),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate file =="
git ls-files | rg '(^|/)plugins/inventory/flightctl\.py$|test.*flightctl|flightctl'

echo "== relevant source =="
wc -l plugins/inventory/flightctl.py
sed -n '240,295p' plugins/inventory/flightctl.py
sed -n '440,505p' plugins/inventory/flightctl.py

echo "== open_url validate_certs usages =="
rg -n "verify_ssl|validate_certs|open_url|oidc_password_grant|_build_auth_headers|_setup_connection_configuration" plugins/inventory/flightctl.py

Repository: flightctl/flightctl-ansible

Length of output: 10304


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== option declarations / documentation around verify_ssl =="
rg -n -C 4 "verify_ssl|flightctl_verify_ssl|ssl_ca_cert|request_timeout|password:" plugins/inventory/flightctl.py

echo "== oidc auth helper =="
sed -n '1,260p' plugins/module_utils/oidc_auth.py

echo "== tests around verify_ssl/inventory options =="
rg -n -C 3 "verify_ssl|verify_ssl:*|test.*verify|oidc_password_grant|_setup_connection_configuration|_build_auth_headers" tests/unit/plugins/inventory/test_flightctl.py tests/integration/targets/inventory_flightctl plugins/inventory/flightctl.py

Repository: flightctl/flightctl-ansible

Length of output: 28823


Make TLS certificate validation the default for the password grant.

When verify_ssl is omitted and no config value overrides it, _setup_connection_configuration falls through to False and stores it on the Configuration object. _build_auth_headers then forwards False into oidc_password_grant(), which disables validate_certs for OIDC discovery and the password POST. Use True as the fallback; keep False only for explicit verify_ssl: false use unless the config file explicitly disables it. Add coverage for the omitted-option case.
[security_AND_privacy]

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/inventory/flightctl.py` around lines 475 - 482, Update
_setup_connection_configuration so an omitted verify_ssl option defaults to True
and preserves False only when explicitly configured, allowing
_build_auth_headers to pass certificate validation to oidc_password_grant. Add
coverage for the omitted-option case and verify the resulting Configuration
value remains True.

Source: Path instructions

Comment thread plugins/inventory/flightctl.py
Comment thread plugins/module_utils/api_module.py
Comment thread plugins/module_utils/oidc_auth.py Outdated
Comment on lines +29 to +32
def http_get_json(url: str, verify_ssl: bool, ca_path: Optional[str], request_timeout: Optional[float]) -> Dict[str, Any]:
response = open_url(url, method='GET', validate_certs=verify_ssl, ca_path=ca_path,
timeout=request_timeout or 30)
return json.loads(response.read())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files:"
fd -a 'oidc_auth.py|urls.py' . | sed 's#^\./##'

echo
echo "oidc_auth outline:"
ast-grep outline plugins/module_utils/oidc_auth.py || true

echo
echo "Relevant oidc_auth sections:"
sed -n '1,180p' plugins/module_utils/oidc_auth.py | cat -n

echo
echo "Search open_url usages and redirects in urls.py if available:"
rg -n "open_url|follow_redirects|follow_redirect" plugins/module_utils/oidc_auth.py plugins/module_utils/urls.py --glob '*.py' || true

echo
echo "urls.py relevant snippet around redirect handling (first matching file):"
target=$(git ls-files | rg '(^|/)urls\.py$' | head -n 1 || true)
if [ -n "${target}" ]; then
  echo "target=$target"
  rg -n -C 6 "follow_redirects|307|308|preserve" "$target" || true
fi

Repository: flightctl/flightctl-ansible

Length of output: 8365


🌐 Web query:

Ansible module_utils.urls open_url follow_redirects default urllib2 POST 307 308

💡 Result:

In Ansible's module_utils.urls, the open_url function and its associated redirect handler implement custom redirection logic that distinguishes between different follow_redirects configurations [1][2]. When follow_redirects is set to urllib2, Ansible delegates redirection behavior to the standard Python urllib2 (now urllib.request) library [1][3]. Because urllib2 is intended to mimic standard Python behavior, it does not inherently treat HTTP 307 or 308 status codes as automatic redirects for POST requests [3][4]. When follow_redirects is set to all or safe, Ansible's custom logic takes over to handle redirects, including 307 and 308 statuses [1][5]. Specifically, for 307 and 308 status codes, Ansible's implementation is designed to preserve the request payload and headers [1][5]. This allows POST requests to be redirected to the new location without being converted to GET requests, provided the chosen follow_redirects mode allows the redirection to proceed [1][3]. In summary: - The urllib2 mode defers to standard library behavior, which generally does not automatically follow 307/308 redirects for POST requests [3][4]. - The all and safe modes use Ansible's custom handler, which explicitly supports 307/308 redirects while preserving the request data and headers [1][5].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Relevant tests:"
sed -n '1,260p' tests/unit/plugins/module_utils/test_oidc_auth.py | cat -n

echo
echo "Check installed Ansible availability:"
python3 - <<'PY'
import importlib.util
print("ansible.module_utils.urls:", importlib.util.find_spec("ansible.module_utils.urls") is not None)
PY

echo
echo "Parse return type usage with a small AST probe:"
python3 - <<'PY'
import ast
from pathlib import Path
path = Path("plugins/module_utils/oidc_auth.py")
tree = ast.parse(path.read_text())
nodes = {}
for name, cls in ast.iter_fields(tree):
    pass
for node in ast.walk(tree):
    if isinstance(node, ast.FunctionDef):
        for stmt in node.body:
            if isinstance(stmt, ast.Return) and isinstance(stmt.value, ast.Call) and isinstance(stmt.value.func, ast.Name) and stmt.value.func.id == "open_url":
                print(f"{node.name}: open_url call at line {node.lineno}, function annotations: {node.returns}")
PY

Repository: flightctl/flightctl-ansible

Length of output: 10667


Validate OIDC discovery values before posting the password.

http_get_json() returns unvalidated json.loads() data. Auth config (auth_config.get()), provider spec (provider.get(), spec.get()), discovery (discovery.get('issuer'), discovery.get('token_endpoint')), and the token response (token_data.get()) are trust-boundary data that can be non-object, non-string, HTTP-based, or mismatched with the configured issuer. Add explicit JSON-object/field/URL allow-list checks before oidc_password_grant() sends the password.

🧰 Tools
🪛 Flake8 (7.3.0)

[error] 31-31: continuation line over-indented for visual indent

(E127)

🪛 Ruff (0.16.0)

[warning] 29-29: Boolean-typed positional argument in function definition

(FBT001)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/module_utils/oidc_auth.py` around lines 29 - 32, Validate all
trust-boundary data before oidc_password_grant() sends credentials: ensure
http_get_json() returns a JSON object, validate auth_config/provider/spec and
token_data object shapes and required string fields, and require discovery
issuer/token_endpoint URLs to be allowed HTTPS URLs matching the configured
issuer where applicable. Perform these checks before constructing or posting the
password grant, rejecting malformed, HTTP, or mismatched values.

Source: Path instructions

Comment on lines +31 to +73
def test_init_with_config_file_still_raises_when_jsonschema_missing(self, monkeypatch, tmp_path):
monkeypatch.setattr(config_loader, 'JSONSCHEMA_IMPORT_ERROR', ImportError('no module named jsonschema'))
config_file = tmp_path / "client.yaml"
config_file.write_text("authentication:\n access-token: abc\nservice:\n server: https://example.com\n")

with pytest.raises(ImportError, match="no module named jsonschema"):
ConfigLoader(config_file=str(config_file))

def test_init_with_config_file_still_raises_when_pyyaml_missing(self, monkeypatch, tmp_path):
monkeypatch.setattr(config_loader, 'PYYAML_IMPORT_ERROR', ImportError('no module named yaml'))
config_file = tmp_path / "client.yaml"
config_file.write_text("authentication:\n access-token: abc\nservice:\n server: https://example.com\n")

with pytest.raises(ImportError, match="no module named yaml"):
ConfigLoader(config_file=str(config_file))


class TestConfigLoaderParsing:
"""Sanity checks that normal config file parsing still works when dependencies are present."""

def test_parses_token_host_and_organization(self, tmp_path):
config_file = tmp_path / "client.yaml"
config_file.write_text(
"organization: my-org\n"
"authentication:\n"
" access-token: my-access-token\n"
"service:\n"
" server: https://flightctl.example.com\n"
" insecureSkipVerify: true\n"
)

loader = ConfigLoader(config_file=str(config_file))

assert loader.token == "my-access-token"
assert loader.organization == "my-org"
assert loader.host == "https://flightctl.example.com"
assert loader.verify_ssl is False

def test_missing_config_file_raises_clear_error(self, tmp_path):
missing_path = tmp_path / "does_not_exist.yaml"

with pytest.raises(Exception, match="was not found"):
ConfigLoader(config_file=str(missing_path))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Mock filesystem operations in these unit tests.

These tests create real files through tmp_path. Mock open to return YAML content or raise FileNotFoundError. This keeps the tests focused on ConfigLoader behavior.

As per path instructions, “Mock external dependencies (API calls, filesystem), not internal logic.”

🧰 Tools
🪛 Ruff (0.16.0)

[error] 64-64: Possible hardcoded password assigned to: "token"

(S105)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/plugins/module_utils/test_config_loader.py` around lines 31 - 73,
Update the ConfigLoader tests in TestConfigLoaderParsing and the
dependency-error tests to mock filesystem access instead of creating files with
tmp_path. Patch the open operation used by ConfigLoader to return the required
YAML content for successful and dependency-error cases, and raise
FileNotFoundError for the missing-file case; preserve the existing assertions
and exception expectations.

Source: Path instructions

Comment on lines +13 to +17
def _fake_http_response(data):
"""Build a stand-in for what ansible.module_utils.urls.open_url() returns."""
response = MagicMock()
response.read.return_value = json.dumps(data).encode('utf-8')
return response

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add type annotations to the new test signatures.

The listed new helpers and test functions omit required signature annotations. Add parameter annotations where applicable and -> None return annotations to test functions.

  • tests/unit/plugins/module_utils/test_oidc_auth.py#L13-L17: annotate _fake_http_response.
  • tests/unit/plugins/module_utils/test_oidc_auth.py#L41-L208: annotate the new test methods.
  • tests/unit/plugins/inventory/test_flightctl.py#L535-L539: annotate _fake_http_response.
  • tests/unit/plugins/inventory/test_flightctl.py#L563-L650: annotate the new test methods.
  • tests/unit/plugins/module_utils/test_api_module.py#L136-L194: annotate the new test functions.
  • tests/unit/plugins/module_utils/test_imagebuilder_module.py#L26-L91: annotate the helper and new test methods.

As per path instructions, “Use type hints for function signatures.”

🧰 Tools
🪛 ast-grep (0.45.0)

[info] 15-15: use jsonify instead of json.dumps for JSON output
Context: json.dumps(data)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

🪛 Ruff (0.16.0)

[warning] 13-13: Missing return type annotation for private function _fake_http_response

(ANN202)

📍 Affects 4 files
  • tests/unit/plugins/module_utils/test_oidc_auth.py#L13-L17 (this comment)
  • tests/unit/plugins/module_utils/test_oidc_auth.py#L41-L208
  • tests/unit/plugins/inventory/test_flightctl.py#L535-L539
  • tests/unit/plugins/inventory/test_flightctl.py#L563-L650
  • tests/unit/plugins/module_utils/test_api_module.py#L136-L194
  • tests/unit/plugins/module_utils/test_imagebuilder_module.py#L26-L91
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/plugins/module_utils/test_oidc_auth.py` around lines 13 - 17, New
test helpers and test functions lack required type annotations. In
tests/unit/plugins/module_utils/test_oidc_auth.py lines 13-17 and 41-208,
tests/unit/plugins/inventory/test_flightctl.py lines 535-539 and 563-650,
tests/unit/plugins/module_utils/test_api_module.py lines 136-194, and
tests/unit/plugins/module_utils/test_imagebuilder_module.py lines 26-91,
annotate helper parameters and add -> None to every new test function or method,
using appropriate existing types for helper inputs and preserving test behavior.

Source: Path instructions

…ken exchange, and fix flake8 lint

and check sanity

Assisted-by: Cursor/Claude
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