Skip to content

fix: allow underscores in parent field type fragment (LFXV2-1652)#50

Merged
jordane merged 1 commit into
mainfrom
jme/LFXV2-1652
May 6, 2026
Merged

fix: allow underscores in parent field type fragment (LFXV2-1652)#50
jordane merged 1 commit into
mainfrom
jme/LFXV2-1652

Conversation

@jordane
Copy link
Copy Markdown
Member

@jordane jordane commented May 5, 2026

Summary

  • Relaxes the parent query param regex from ^[a-zA-Z]+:[a-zA-Z0-9_-]+$ to ^[a-zA-Z][a-zA-Z0-9_]*:[a-zA-Z0-9_-]+$ so resource types containing underscores (e.g. past_meeting, v1_past_meeting) are accepted
  • Applies the same pattern to the query-resources-count endpoint, which previously had no validation on parent, for consistency
  • Adds a regression test in cmd/service/parent_regex_test.go covering valid and invalid parent formats

Fixes: LFXV2-1652

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 5, 2026 23:25
@jordane jordane requested a review from a team as a code owner May 5, 2026 23:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9246d21f-e7a3-4548-943d-222222287ce9

📥 Commits

Reviewing files that changed from the base of the PR and between 5e82a56 and 267d883.

⛔ Files ignored due to path filters (6)
  • gen/http/openapi.json is excluded by !**/gen/**
  • gen/http/openapi.yaml is excluded by !**/gen/**
  • gen/http/openapi3.json is excluded by !**/gen/**
  • gen/http/openapi3.yaml is excluded by !**/gen/**
  • gen/http/query_svc/client/cli.go is excluded by !**/gen/**
  • gen/http/query_svc/server/encode_decode.go is excluded by !**/gen/**
📒 Files selected for processing (2)
  • cmd/service/parent_regex_test.go
  • design/query-svc.go

Walkthrough

A parent field regex pattern is tightened in the query service design DSL to require the prefix to start with a letter; a new Go test file validates the updated pattern against expected valid and invalid inputs.

Changes

Parent Pattern Validation

Layer / File(s) Summary
Pattern Definition
design/query-svc.go
Updated parent attribute pattern in two payloads (lines ~45–49 and ~145–149) from ^[a-zA-Z]+:[a-zA-Z0-9_-]+$ to ^[a-zA-Z][a-zA-Z0-9_]*:[a-zA-Z0-9_-]+$ (prefix must start with a letter; subsequent chars may include digits or underscores).
Test Coverage
cmd/service/parent_regex_test.go
Added test file declaring parentPattern and TestParentPattern, asserting several valid strings match and several invalid strings do not.
Misc / Manifest
go.mod
Module file present (no functional API changes beyond pattern/test).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: relaxing the parent field regex to allow underscores in resource type fragments.
Description check ✅ Passed The description is directly related to the changeset, detailing the regex pattern changes, affected endpoints, and the addition of regression tests.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jme/LFXV2-1652

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Query Service’s parent query parameter validation to accept resource type fragments containing underscores (and digits after the first character), and applies the same validation consistently across both the /query/resources and /query/resources/count endpoints. This aligns runtime request decoding, CLI payload validation, and the generated OpenAPI specs with the updated contract.

Changes:

  • Relaxed parent regex validation to ^[a-zA-Z][a-zA-Z0-9_]*:[a-zA-Z0-9_-]+$ to support types like past_meeting and v1_past_meeting.
  • Added missing parent validation to the query-resources-count endpoint for parity with query-resources.
  • Added a regression unit test to lock in the expected parent format.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
gen/http/query_svc/server/encode_decode.go Updates/extends server-side request decoding validation for parent on both endpoints.
gen/http/query_svc/client/cli.go Updates/extends CLI payload validation for parent on both endpoints.
gen/http/openapi3.yaml Updates OpenAPI v3 schema patterns for parent (including count endpoint).
gen/http/openapi3.json Regenerates OpenAPI v3 JSON reflecting updated parent pattern.
gen/http/openapi.yaml Updates Swagger/OpenAPI v2 schema patterns for parent (including count endpoint).
gen/http/openapi.json Regenerates Swagger/OpenAPI v2 JSON reflecting updated parent pattern.
design/query-svc.go Updates Goa design parent pattern and applies it to query-resources-count.
cmd/service/parent_regex_test.go Adds a regression test covering valid/invalid parent formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/service/parent_regex_test.go Outdated
Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (1)
cmd/service/parent_regex_test.go (1)

8-12: ⚡ Quick win

Avoid regex duplication in the test; colocate with implementation and reuse a shared constant.

Line 10 hardcodes a second copy of the production regex. That can drift over time and reduces the value of this regression test. Prefer defining one shared constant in design/query-svc.go, then use it from a colocated design/*_test.go test.

♻️ Proposed refactor
--- a/design/query-svc.go
+++ b/design/query-svc.go
@@
 package design
@@
+const ParentPattern = `^[a-zA-Z][a-zA-Z0-9_]*:[a-zA-Z0-9_-]+$`
@@
-               dsl.Pattern(`^[a-zA-Z][a-zA-Z0-9_]*:[a-zA-Z0-9_-]+$`)
+               dsl.Pattern(ParentPattern)
@@
-               dsl.Pattern(`^[a-zA-Z][a-zA-Z0-9_]*:[a-zA-Z0-9_-]+$`)
+               dsl.Pattern(ParentPattern)
--- a/cmd/service/parent_regex_test.go
+++ b/design/parent_regex_test.go
@@
-package service_test
+package design
@@
-const parentPattern = `^[a-zA-Z][a-zA-Z0-9_]*:[a-zA-Z0-9_-]+$`
+const parentPattern = ParentPattern

As per coding guidelines, **/*_test.go: Test files should follow the *_test.go naming pattern and be placed alongside their implementation files.

🤖 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 `@cmd/service/parent_regex_test.go` around lines 8 - 12, The test duplicates
the production regex (parentPattern) which can drift; remove the hardcoded const
in cmd/service/parent_regex_test.go and instead reference the single source of
truth defined in design/query-svc.go (e.g., the existing parentPattern constant)
by colocating the test next to that implementation as
design/parent_regex_test.go and using TestParentPattern to assert the same
behavior; if the constant is unexported and the test needs package access, place
the test in the same package (not package_test) or make the constant exported so
the test can reuse the implementation constant rather than duplicating it.
🤖 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 `@cmd/service/parent_regex_test.go`:
- Line 1: Add the project's required license header at the very top of this file
above the package declaration (package service_test) so CI's license-check
passes; insert the exact canonical license block used across the repo (copy from
other files) as the first lines, keeping the existing package service_test line
unchanged.

---

Nitpick comments:
In `@cmd/service/parent_regex_test.go`:
- Around line 8-12: The test duplicates the production regex (parentPattern)
which can drift; remove the hardcoded const in cmd/service/parent_regex_test.go
and instead reference the single source of truth defined in design/query-svc.go
(e.g., the existing parentPattern constant) by colocating the test next to that
implementation as design/parent_regex_test.go and using TestParentPattern to
assert the same behavior; if the constant is unexported and the test needs
package access, place the test in the same package (not package_test) or make
the constant exported so the test can reuse the implementation constant rather
than duplicating it.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dbc592dd-8042-48c9-ae19-e5991e1dffc6

📥 Commits

Reviewing files that changed from the base of the PR and between 43b083b and 5e82a56.

⛔ Files ignored due to path filters (6)
  • gen/http/openapi.json is excluded by !**/gen/**
  • gen/http/openapi.yaml is excluded by !**/gen/**
  • gen/http/openapi3.json is excluded by !**/gen/**
  • gen/http/openapi3.yaml is excluded by !**/gen/**
  • gen/http/query_svc/client/cli.go is excluded by !**/gen/**
  • gen/http/query_svc/server/encode_decode.go is excluded by !**/gen/**
📒 Files selected for processing (2)
  • cmd/service/parent_regex_test.go
  • design/query-svc.go

Comment thread cmd/service/parent_regex_test.go Outdated
Relaxes the `parent` query param regex from `^[a-zA-Z]+:...` to
`^[a-zA-Z][a-zA-Z0-9_]*:...` so resource types like `past_meeting`
and `v1_past_meeting` are accepted. Also applies the same pattern to
the `query-resources-count` endpoint for consistency and adds a
regression test.

Issue: LFXV2-1652

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Jordan Evans <jevans@linuxfoundation.org>
@jordane jordane merged commit 7575c2f into main May 6, 2026
9 checks passed
@jordane jordane deleted the jme/LFXV2-1652 branch May 6, 2026 00:01
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.

5 participants