fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE #3290

Merged
freemo merged 1 commit from fix/resource-type-namespaced-re-digit-start into master 2026-04-05 21:12:25 +00:00
Owner

Summary

Fixes _NAMESPACED_RE in resource_type.py and _resource_type_validation.py to require both namespace and name components to start with a letter, consistent with the spec requirement and _BUILTIN_NAME_RE.

Problem

The _NAMESPACED_RE pattern used [a-zA-Z0-9] as the first character class, allowing digit-starting names like 123abc/my-type and local/456-type. This was inconsistent with:

  • _BUILTIN_NAME_RE which correctly uses [a-zA-Z]
  • The spec requirement that names start with a letter
  • _SERVER_NS_NAME_RE in project.py

Changes

src/cleveragents/domain/models/core/resource_type.py

  • Changed _NAMESPACED_RE from ^[a-zA-Z0-9][a-zA-Z0-9_-]*/[a-zA-Z0-9][a-zA-Z0-9_-]*$ to ^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$
  • Updated docstring comment to reflect the letter-start requirement

src/cleveragents/domain/models/core/_resource_type_validation.py

  • Changed _NAMESPACED_RE from ^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$ to ^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$

features/resource_type_digit_start_validation.feature (new)

  • Added 8 Behave scenarios covering:
    • Rejection of digit-starting namespace (123abc/my-type)
    • Rejection of digit-starting name component (local/456-type)
    • Rejection of digit-starting both components (1ns/2name)
    • Acceptance of valid letter-starting names (local/my-type, myorg/custom-db, my_org/my_type)
    • Rejection of digit-starting inherits field values

features/steps/resource_type_digit_start_validation_steps.py (new)

  • Step definitions for the new feature file

Verification

  • ResourceTypeSpec(name="123abc/my-type", ...) now raises ValidationError
  • ResourceTypeSpec(name="local/456-type", ...) now raises ValidationError
  • ResourceTypeSpec(name="local/my-type", ...) still succeeds ✓
  • ResourceTypeSpec(name="myorg/custom-db", ...) still succeeds ✓
  • nox -e lint passes ✓
  • nox -e typecheck passes (0 errors, 0 warnings) ✓

Closes #2983


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

## Summary Fixes `_NAMESPACED_RE` in `resource_type.py` and `_resource_type_validation.py` to require both namespace and name components to start with a letter, consistent with the spec requirement and `_BUILTIN_NAME_RE`. ## Problem The `_NAMESPACED_RE` pattern used `[a-zA-Z0-9]` as the first character class, allowing digit-starting names like `123abc/my-type` and `local/456-type`. This was inconsistent with: - `_BUILTIN_NAME_RE` which correctly uses `[a-zA-Z]` - The spec requirement that names start with a letter - `_SERVER_NS_NAME_RE` in `project.py` ## Changes ### `src/cleveragents/domain/models/core/resource_type.py` - Changed `_NAMESPACED_RE` from `^[a-zA-Z0-9][a-zA-Z0-9_-]*/[a-zA-Z0-9][a-zA-Z0-9_-]*$` to `^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$` - Updated docstring comment to reflect the letter-start requirement ### `src/cleveragents/domain/models/core/_resource_type_validation.py` - Changed `_NAMESPACED_RE` from `^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$` to `^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$` ### `features/resource_type_digit_start_validation.feature` (new) - Added 8 Behave scenarios covering: - Rejection of digit-starting namespace (`123abc/my-type`) - Rejection of digit-starting name component (`local/456-type`) - Rejection of digit-starting both components (`1ns/2name`) - Acceptance of valid letter-starting names (`local/my-type`, `myorg/custom-db`, `my_org/my_type`) - Rejection of digit-starting `inherits` field values ### `features/steps/resource_type_digit_start_validation_steps.py` (new) - Step definitions for the new feature file ## Verification - `ResourceTypeSpec(name="123abc/my-type", ...)` now raises `ValidationError` ✓ - `ResourceTypeSpec(name="local/456-type", ...)` now raises `ValidationError` ✓ - `ResourceTypeSpec(name="local/my-type", ...)` still succeeds ✓ - `ResourceTypeSpec(name="myorg/custom-db", ...)` still succeeds ✓ - `nox -e lint` passes ✓ - `nox -e typecheck` passes (0 errors, 0 warnings) ✓ Closes #2983 --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE
All checks were successful
CI / lint (pull_request) Successful in 21s
CI / typecheck (pull_request) Successful in 47s
CI / quality (pull_request) Successful in 35s
CI / security (pull_request) Successful in 1m3s
CI / build (pull_request) Successful in 18s
CI / helm (pull_request) Successful in 23s
CI / unit_tests (pull_request) Successful in 6m41s
CI / e2e_tests (pull_request) Successful in 18m1s
CI / integration_tests (pull_request) Successful in 22m59s
CI / docker (pull_request) Successful in 1m22s
CI / coverage (pull_request) Successful in 11m29s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 58m55s
c1dca80bf2
Update _NAMESPACED_RE in resource_type.py and _resource_type_validation.py
to require both namespace and name components to start with a letter, consistent
with _BUILTIN_NAME_RE and the spec requirement that names start with a letter.

Previously, _NAMESPACED_RE used [a-zA-Z0-9] as the first character class,
allowing digit-starting names like '123abc/my-type'. Now uses [a-zA-Z] to
enforce letter-start for both components.

Also adds Behave scenarios covering rejection of digit-starting custom resource
type names and valid letter-starting names.

ISSUES CLOSED: #2983
freemo added this to the v3.7.0 milestone 2026-04-05 09:14:20 +00:00
freemo left a comment

Review Summary

Reviewed PR #3290 with focus on api-consistency, naming-conventions, and code-patterns.

This is a clean, well-scoped bug fix that corrects _NAMESPACED_RE regex patterns in two files to require letter-start for both namespace and name components, aligning with the spec requirement and the existing _BUILTIN_NAME_RE / _SERVER_NS_NAME_RE patterns.

Verdict: This PR is ready for approval.

Specification Compliance

  • The spec defines the name format as [[server:]namespace/]name and the glossary entry for "Namespace" confirms letter-start convention
  • _SERVER_NS_NAME_RE in project.py (line 32-36) already uses [a-zA-Z] for first character — this PR brings _NAMESPACED_RE into alignment
  • _BUILTIN_NAME_RE already uses [a-zA-Z] — consistency is now restored

API Consistency (Focus Area)

  • Both _NAMESPACED_RE definitions (in resource_type.py and _resource_type_validation.py) are now identical: ^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$
  • Cross-module consistency: The pattern now matches the structure used in _SERVER_NS_NAME_RE in project.py and _BUILTIN_NAME_RE in both files
  • Validation behavior: Both validate_name() and validate_inherits() validators correctly use the updated pattern through the module-level _NAMESPACED_RE

Naming Conventions (Focus Area)

  • Variable names follow existing project conventions (_NAMESPACED_RE, _BUILTIN_NAME_RE)
  • Feature file name resource_type_digit_start_validation.feature follows project naming patterns
  • Step file name resource_type_digit_start_validation_steps.py follows the <feature>_steps.py convention
  • Helper function _make_custom_physical_spec() follows the _ prefix convention for internal helpers

Code Patterns (Focus Area)

  • The regex fix is minimal and targeted — only the character class for the first character was changed
  • Step definitions follow the established pattern: try/except capturing ValidationError into context.rt_error
  • Background step correctly reuses the existing given step from resource_type_model_coverage_steps.py
  • The then step for "invalid inherits type name" is correctly reused from resource_type_model_coverage_steps.py (noted in the step file docstring)

CONTRIBUTING.md Compliance

  • Commit message: fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE — correct Conventional Changelog format ✓
  • Issue footer: ISSUES CLOSED: #2983
  • PR metadata: Closes #2983, milestone v3.7.0 (matches issue), Type/Bug label ✓
  • Single atomic commit with implementation + tests ✓
  • No forbidden patterns: No # type: ignore, imports at top of file ✓

Test Quality

  • 8 Behave scenarios covering:
    • 3 rejection cases (digit-starting namespace, name, both)
    • 3 acceptance cases (letter-starting with various valid characters)
    • 2 inherits field rejection cases
  • Assertions check both that errors are raised AND that error messages contain expected text
  • Step definitions are clean, well-documented, and properly typed

Code Correctness

  • The regex change from [a-zA-Z0-9][a-zA-Z] is correct for the stated requirement
  • Bonus fix in _resource_type_validation.py: The old pattern ^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$ was even more permissive — it allowed names starting with hyphens or underscores (e.g., _ns/name, -ns/name). The new pattern correctly prevents this too.

Minor Suggestions (Non-blocking)

  1. DRY concern — duplicate _NAMESPACED_RE definitions: Both resource_type.py and _resource_type_validation.py define their own _NAMESPACED_RE (and _BUILTIN_NAME_RE). If someone changes one but not the other in the future, the inconsistency bug could recur. Consider a follow-up issue to consolidate these into a single shared location (e.g., the validation module exports them, and resource_type.py imports). This is a pre-existing design issue, not introduced by this PR.

  2. Additional edge case tests: Since the _resource_type_validation.py fix also prevents names starting with hyphens or underscores (which the old [a-zA-Z0-9_-]+ pattern allowed), consider adding scenarios for _ns/name and -ns/name rejection in a follow-up. Again, not blocking for this PR since the issue scope was specifically digit-starting names.

Decision: APPROVED


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer

## Review Summary Reviewed PR #3290 with focus on **api-consistency**, **naming-conventions**, and **code-patterns**. This is a clean, well-scoped bug fix that corrects `_NAMESPACED_RE` regex patterns in two files to require letter-start for both namespace and name components, aligning with the spec requirement and the existing `_BUILTIN_NAME_RE` / `_SERVER_NS_NAME_RE` patterns. **Verdict: This PR is ready for approval.** ### ✅ Specification Compliance - The spec defines the name format as `[[server:]namespace/]name` and the glossary entry for "Namespace" confirms letter-start convention - `_SERVER_NS_NAME_RE` in `project.py` (line 32-36) already uses `[a-zA-Z]` for first character — this PR brings `_NAMESPACED_RE` into alignment - `_BUILTIN_NAME_RE` already uses `[a-zA-Z]` — consistency is now restored ### ✅ API Consistency (Focus Area) - **Both `_NAMESPACED_RE` definitions** (in `resource_type.py` and `_resource_type_validation.py`) are now identical: `^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$` - **Cross-module consistency**: The pattern now matches the structure used in `_SERVER_NS_NAME_RE` in `project.py` and `_BUILTIN_NAME_RE` in both files - **Validation behavior**: Both `validate_name()` and `validate_inherits()` validators correctly use the updated pattern through the module-level `_NAMESPACED_RE` ### ✅ Naming Conventions (Focus Area) - Variable names follow existing project conventions (`_NAMESPACED_RE`, `_BUILTIN_NAME_RE`) - Feature file name `resource_type_digit_start_validation.feature` follows project naming patterns - Step file name `resource_type_digit_start_validation_steps.py` follows the `<feature>_steps.py` convention - Helper function `_make_custom_physical_spec()` follows the `_` prefix convention for internal helpers ### ✅ Code Patterns (Focus Area) - The regex fix is minimal and targeted — only the character class for the first character was changed - Step definitions follow the established pattern: try/except capturing `ValidationError` into `context.rt_error` - Background step correctly reuses the existing `given` step from `resource_type_model_coverage_steps.py` - The `then` step for "invalid inherits type name" is correctly reused from `resource_type_model_coverage_steps.py` (noted in the step file docstring) ### ✅ CONTRIBUTING.md Compliance - **Commit message**: `fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE` — correct Conventional Changelog format ✓ - **Issue footer**: `ISSUES CLOSED: #2983` ✓ - **PR metadata**: `Closes #2983`, milestone v3.7.0 (matches issue), `Type/Bug` label ✓ - **Single atomic commit** with implementation + tests ✓ - **No forbidden patterns**: No `# type: ignore`, imports at top of file ✓ ### ✅ Test Quality - 8 Behave scenarios covering: - 3 rejection cases (digit-starting namespace, name, both) - 3 acceptance cases (letter-starting with various valid characters) - 2 `inherits` field rejection cases - Assertions check both that errors are raised AND that error messages contain expected text - Step definitions are clean, well-documented, and properly typed ### ✅ Code Correctness - The regex change from `[a-zA-Z0-9]` → `[a-zA-Z]` is correct for the stated requirement - **Bonus fix in `_resource_type_validation.py`**: The old pattern `^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$` was even more permissive — it allowed names starting with hyphens or underscores (e.g., `_ns/name`, `-ns/name`). The new pattern correctly prevents this too. ### Minor Suggestions (Non-blocking) 1. **DRY concern — duplicate `_NAMESPACED_RE` definitions**: Both `resource_type.py` and `_resource_type_validation.py` define their own `_NAMESPACED_RE` (and `_BUILTIN_NAME_RE`). If someone changes one but not the other in the future, the inconsistency bug could recur. Consider a follow-up issue to consolidate these into a single shared location (e.g., the validation module exports them, and `resource_type.py` imports). This is a pre-existing design issue, not introduced by this PR. 2. **Additional edge case tests**: Since the `_resource_type_validation.py` fix also prevents names starting with hyphens or underscores (which the old `[a-zA-Z0-9_-]+` pattern allowed), consider adding scenarios for `_ns/name` and `-ns/name` rejection in a follow-up. Again, not blocking for this PR since the issue scope was specifically digit-starting names. **Decision: APPROVED** ✅ --- **Automated by CleverAgents Bot** Supervisor: PR Review | Agent: ca-pr-self-reviewer
freemo requested reviews from khird, drew 2026-04-05 17:59:24 +00:00
Author
Owner

PR Status Update — Awaiting Review

This PR is ready for review. Here is the current status:

CI Checks

All critical CI checks are passing:

  • lint | typecheck | unit_tests | coverage
  • integration_tests | e2e_tests | docker | helm
  • security | quality | build | status-check

The benchmark-regression and benchmark-publish checks are pending (these are non-blocking performance checks that run asynchronously).

Merge Readiness

  • No merge conflicts with master
  • Correct dependency direction: PR #3290 blocks issue #2983
  • Issue #2983 is in State/In Review
  • Milestone: v3.7.0
  • Type label: Type/Bug

Blocking: Needs 2 Approving Reviews

Per CONTRIBUTING.md, this PR requires 2 approving reviews from non-author contributors. Currently there are 0 official approvals.

Review requests have been sent to @khird and @drew.

What This PR Does

Fixes _NAMESPACED_RE in resource_type.py and _resource_type_validation.py to require both namespace and name components to start with a letter (changing [a-zA-Z0-9][a-zA-Z] for the first character class). This aligns with the spec requirement, _BUILTIN_NAME_RE, and _SERVER_NS_NAME_RE in project.py.

The fix is minimal, targeted, and includes 8 Behave scenarios covering rejection and acceptance cases.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

## PR Status Update — Awaiting Review This PR is **ready for review**. Here is the current status: ### ✅ CI Checks All critical CI checks are passing: - lint ✅ | typecheck ✅ | unit_tests ✅ | coverage ✅ - integration_tests ✅ | e2e_tests ✅ | docker ✅ | helm ✅ - security ✅ | quality ✅ | build ✅ | status-check ✅ The `benchmark-regression` and `benchmark-publish` checks are pending (these are non-blocking performance checks that run asynchronously). ### ✅ Merge Readiness - No merge conflicts with master - Correct dependency direction: PR #3290 blocks issue #2983 ✅ - Issue #2983 is in `State/In Review` ✅ - Milestone: v3.7.0 ✅ - Type label: `Type/Bug` ✅ ### ❌ Blocking: Needs 2 Approving Reviews Per CONTRIBUTING.md, this PR requires **2 approving reviews from non-author contributors**. Currently there are 0 official approvals. Review requests have been sent to @khird and @drew. ### What This PR Does Fixes `_NAMESPACED_RE` in `resource_type.py` and `_resource_type_validation.py` to require both namespace and name components to start with a letter (changing `[a-zA-Z0-9]` → `[a-zA-Z]` for the first character class). This aligns with the spec requirement, `_BUILTIN_NAME_RE`, and `_SERVER_NS_NAME_RE` in `project.py`. The fix is minimal, targeted, and includes 8 Behave scenarios covering rejection and acceptance cases. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
freemo left a comment

Independent Code Review — PR #3290

Reviewed PR #3290 with focus on api-consistency, naming-conventions, and code-patterns.

This is a clean, well-scoped bug fix that corrects _NAMESPACED_RE regex patterns in two files to require letter-start for both namespace and name components, aligning with the spec requirement and the existing _BUILTIN_NAME_RE pattern.

Verdict: No issues found. This PR is ready for human reviewer approval.

Specification Compliance

  • The spec defines the name format as [[server:]namespace/]name with letter-start requirement
  • _BUILTIN_NAME_RE already uses [a-zA-Z] — consistency is now restored across both modules
  • _SERVER_NS_NAME_RE in project.py already enforces letter-start — this PR brings _NAMESPACED_RE into alignment

API Consistency (Focus Area — Deep Dive)

  • Both _NAMESPACED_RE definitions (in resource_type.py and _resource_type_validation.py) are now identical: ^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$
  • Cross-module consistency: The pattern now matches the structure used in _BUILTIN_NAME_RE in both files
  • Validation behavior: Both validate_name() and validate_inherits() validators correctly use the updated pattern through the module-level _NAMESPACED_RE
  • Bonus fix in _resource_type_validation.py: The old pattern ^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$ was even more permissive than the one in resource_type.py — it allowed names starting with hyphens or underscores (e.g., _ns/name, -ns/name). The new pattern correctly prevents this too, bringing both files into perfect alignment.

Naming Conventions (Focus Area — Deep Dive)

  • Variable names follow existing project conventions (_NAMESPACED_RE, _BUILTIN_NAME_RE)
  • Feature file name resource_type_digit_start_validation.feature follows project naming patterns
  • Step file name resource_type_digit_start_validation_steps.py follows the <feature>_steps.py convention
  • Helper function _make_custom_physical_spec() follows the _ prefix convention for internal helpers
  • Step function names are descriptive and follow the step_<action> pattern

Code Patterns (Focus Area — Deep Dive)

  • The regex fix is minimal and targeted — only the character class for the first character was changed
  • Step definitions follow the established pattern: try/except capturing ValidationError into context.rt_error
  • Background step correctly reuses the existing given step from resource_type_model_coverage_steps.py
  • The then step for "invalid inherits type name" is correctly reused from resource_type_model_coverage_steps.py (noted in the step file docstring)
  • Error message assertions check both error type AND message content — consistent with project patterns

CONTRIBUTING.md Compliance

  • Commit message: fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE — correct Conventional Changelog format ✓
  • Issue footer: ISSUES CLOSED: #2983
  • PR body: Closes #2983
  • Milestone: v3.7.0 (matches issue) ✓
  • Label: Type/Bug
  • Single atomic commit with implementation + tests ✓
  • No forbidden patterns: No # type: ignore, imports at top of file ✓

Test Quality

  • 8 Behave scenarios covering:
    • 3 rejection cases (digit-starting namespace, name, both components)
    • 3 acceptance cases (letter-starting with hyphens, org-style, underscores)
    • 2 inherits field rejection cases (digit-starting namespace and name)
  • Assertions check both that errors are raised AND that error messages contain expected text
  • Step definitions are clean, well-documented, and properly typed with return annotations
  • CI confirms all nox sessions pass (lint, typecheck, unit_tests, coverage, integration_tests)

Code Correctness

  • The regex change from [a-zA-Z0-9][a-zA-Z] is correct for the stated requirement
  • The * quantifier after the first character class is correct (first char already matched by [a-zA-Z])
  • No regressions — valid names like local/my-type, myorg/custom-db, my_org/my_type still pass

Minor Suggestions (Non-blocking)

  1. DRY concern — duplicate _NAMESPACED_RE definitions: Both resource_type.py and _resource_type_validation.py define their own _NAMESPACED_RE (and _BUILTIN_NAME_RE). If someone changes one but not the other in the future, the inconsistency bug could recur. Consider a follow-up issue to consolidate these into a single shared location (e.g., the validation module exports them, and resource_type.py imports). This is a pre-existing design issue, not introduced by this PR.

  2. Additional edge case tests: Since the _resource_type_validation.py fix also prevents names starting with hyphens or underscores (which the old [a-zA-Z0-9_-]+ pattern allowed), consider adding scenarios for _ns/name and -ns/name rejection in a follow-up. Not blocking since the issue scope was specifically digit-starting names.

Decision: APPROVED

(Note: Posted as COMMENT because the Forgejo API user matches the PR author. Human reviewers @khird and @drew — this PR is ready for your approval.)


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer

## Independent Code Review — PR #3290 Reviewed PR #3290 with focus on **api-consistency**, **naming-conventions**, and **code-patterns**. This is a clean, well-scoped bug fix that corrects `_NAMESPACED_RE` regex patterns in two files to require letter-start for both namespace and name components, aligning with the spec requirement and the existing `_BUILTIN_NAME_RE` pattern. **Verdict: No issues found. This PR is ready for human reviewer approval.** ### ✅ Specification Compliance - The spec defines the name format as `[[server:]namespace/]name` with letter-start requirement - `_BUILTIN_NAME_RE` already uses `[a-zA-Z]` — consistency is now restored across both modules - `_SERVER_NS_NAME_RE` in `project.py` already enforces letter-start — this PR brings `_NAMESPACED_RE` into alignment ### ✅ API Consistency (Focus Area — Deep Dive) - **Both `_NAMESPACED_RE` definitions** (in `resource_type.py` and `_resource_type_validation.py`) are now identical: `^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$` - **Cross-module consistency**: The pattern now matches the structure used in `_BUILTIN_NAME_RE` in both files - **Validation behavior**: Both `validate_name()` and `validate_inherits()` validators correctly use the updated pattern through the module-level `_NAMESPACED_RE` - **Bonus fix in `_resource_type_validation.py`**: The old pattern `^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$` was even more permissive than the one in `resource_type.py` — it allowed names starting with hyphens or underscores (e.g., `_ns/name`, `-ns/name`). The new pattern correctly prevents this too, bringing both files into perfect alignment. ### ✅ Naming Conventions (Focus Area — Deep Dive) - Variable names follow existing project conventions (`_NAMESPACED_RE`, `_BUILTIN_NAME_RE`) - Feature file name `resource_type_digit_start_validation.feature` follows project naming patterns - Step file name `resource_type_digit_start_validation_steps.py` follows the `<feature>_steps.py` convention - Helper function `_make_custom_physical_spec()` follows the `_` prefix convention for internal helpers - Step function names are descriptive and follow the `step_<action>` pattern ### ✅ Code Patterns (Focus Area — Deep Dive) - The regex fix is minimal and targeted — only the character class for the first character was changed - Step definitions follow the established pattern: try/except capturing `ValidationError` into `context.rt_error` - Background step correctly reuses the existing `given` step from `resource_type_model_coverage_steps.py` - The `then` step for "invalid inherits type name" is correctly reused from `resource_type_model_coverage_steps.py` (noted in the step file docstring) - Error message assertions check both error type AND message content — consistent with project patterns ### ✅ CONTRIBUTING.md Compliance - **Commit message**: `fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE` — correct Conventional Changelog format ✓ - **Issue footer**: `ISSUES CLOSED: #2983` ✓ - **PR body**: `Closes #2983` ✓ - **Milestone**: v3.7.0 (matches issue) ✓ - **Label**: `Type/Bug` ✓ - **Single atomic commit** with implementation + tests ✓ - **No forbidden patterns**: No `# type: ignore`, imports at top of file ✓ ### ✅ Test Quality - 8 Behave scenarios covering: - 3 rejection cases (digit-starting namespace, name, both components) - 3 acceptance cases (letter-starting with hyphens, org-style, underscores) - 2 `inherits` field rejection cases (digit-starting namespace and name) - Assertions check both that errors are raised AND that error messages contain expected text - Step definitions are clean, well-documented, and properly typed with return annotations - CI confirms all nox sessions pass (lint, typecheck, unit_tests, coverage, integration_tests) ### ✅ Code Correctness - The regex change from `[a-zA-Z0-9]` → `[a-zA-Z]` is correct for the stated requirement - The `*` quantifier after the first character class is correct (first char already matched by `[a-zA-Z]`) - No regressions — valid names like `local/my-type`, `myorg/custom-db`, `my_org/my_type` still pass ### Minor Suggestions (Non-blocking) 1. **DRY concern — duplicate `_NAMESPACED_RE` definitions**: Both `resource_type.py` and `_resource_type_validation.py` define their own `_NAMESPACED_RE` (and `_BUILTIN_NAME_RE`). If someone changes one but not the other in the future, the inconsistency bug could recur. Consider a follow-up issue to consolidate these into a single shared location (e.g., the validation module exports them, and `resource_type.py` imports). This is a pre-existing design issue, not introduced by this PR. 2. **Additional edge case tests**: Since the `_resource_type_validation.py` fix also prevents names starting with hyphens or underscores (which the old `[a-zA-Z0-9_-]+` pattern allowed), consider adding scenarios for `_ns/name` and `-ns/name` rejection in a follow-up. Not blocking since the issue scope was specifically digit-starting names. **Decision: APPROVED** ✅ _(Note: Posted as COMMENT because the Forgejo API user matches the PR author. Human reviewers @khird and @drew — this PR is ready for your approval.)_ --- **Automated by CleverAgents Bot** Supervisor: PR Review | Agent: ca-pr-self-reviewer
freemo merged commit 8f43352723 into master 2026-04-05 21:12:18 +00:00
freemo removed this from the v3.7.0 milestone 2026-04-07 00:10:23 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core!3290
No description provided.