Skip to content

fix: make service config optional in API design#325

Merged
rshoemaker merged 1 commit intomainfrom
fix/PLAT-530/optional-config
Apr 8, 2026
Merged

fix: make service config optional in API design#325
rshoemaker merged 1 commit intomainfrom
fix/PLAT-530/optional-config

Conversation

@rshoemaker
Copy link
Copy Markdown
Contributor

@rshoemaker rshoemaker commented Apr 3, 2026

Summary

  • Remove config from required fields in the Goa service spec DSL
  • Add omitempty to the config JSON tag so responses omit empty configs
  • Normalize nil config to map[string]any{} in the API-to-domain conversion layer
  • Update docs to reflect config is now optional
  • Add test coverage for nil config across all service types and for the normalizeConfig helper

Test plan

  • make test passes
  • Create MCP service without config field — should use defaults
  • Create PostgREST service without config field — should use defaults
  • Create RAG service without config field — should return validation error (pipelines required)
  • Existing services with explicit config still work as before

PLAT-530

Remove config from Required fields in the Goa DSL and add omitempty
to the JSON tag. The custom validation layer already handles nil
configs with sensible defaults, but the generated validation was
rejecting requests before custom parsing could run.

Normalize nil config to an empty map in the API conversion layer so
downstream code never needs nil checks.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

Made the config field optional in ServiceSpec by updating its JSON tag to include omitempty and removing it from the required fields list. Updated documentation and added helper function to normalize nil configs to empty maps with test coverage.

Changes

Cohort / File(s) Summary
Database Schema
api/apiv1/design/database.go
Updated config field JSON tag to config,omitempty and removed it from ServiceSpec required fields list, making the field optional.
Conversion Logic
server/internal/api/apiv1/convert.go, convert_test.go
Added normalizeConfig helper function to convert nil maps to empty maps; updated apiToServiceSpec to use it. New test suite validates behavior for nil and non-nil inputs.
Validation Coverage
server/internal/api/apiv1/validate_test.go
Extended TestValidateServiceSpec with test cases covering omitted/nil config across service types (mcp, postgrest, rag) with expected validation outcomes.
Documentation
docs/services/managing.md
Updated service spec documentation to mark config field as optional with description of sensible default behavior when omitted.

Poem

🐰 Config fields hopping to optional shores,
Empty maps dance through conversion's doors,
Tests verify each service type with care,
From mcp to rag, defaults everywhere!
Sensible simplicity, refactored with glee,
Optional configs set the services free! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: making the service config field optional in the API design.
Description check ✅ Passed The pull request description follows the required template structure with Summary, Test plan, and issue reference, and clearly articulates the changes and testing performed.

✏️ 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 fix/PLAT-530/optional-config

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.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@rshoemaker rshoemaker merged commit f26aa71 into main Apr 8, 2026
3 checks passed
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.

2 participants