redhat-developer / redhat-developer/rhdh-plugins
Add Backstage catalog-model utility preference to ai-integrations AGENTS.md
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 120
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 337
Description
What happened
On PR #3956, the code agent implemented OCI validation by manually splitting type:target location-ref strings with indexOf(':'). This manual parsing did not trim whitespace before comparing the type component, causing leading whitespace on a backstage.io/source-location annotation to silently skip OCI validation. The human reviewer (comment) identified that parseLocationRef from @backstage/catalog-model handles trimming, error cases, and type/target extraction correctly — it is the standard upstream utility for exactly this purpose. The fix agent then adopted parseLocationRef in commit 5b65088, resolving the issue. If the code agent had used parseLocationRef from the start, the whitespace bypass bug and subsequent fix rounds would have been avoided. The ai-integrations AGENTS.md has no mention of preferring upstream Backstage utilities.
What could go better
The code agent had no guidance to prefer upstream @backstage/catalog-model utilities over manual implementations. The workspace AGENTS.md covers build commands, architecture, and spec conventions but does not mention the standard Backstage catalog-model utilities that plugins in this workspace should use. This is a high-confidence gap: parseLocationRef, ANNOTATION_SOURCE_LOCATION, parseEntityRef, and similar utilities are foundational to Backstage plugin development and are used throughout the monorepo. Instructing the code agent to prefer these would prevent a recurring class of bugs where manual string parsing misses edge cases the upstream utility handles.
Proposed change
Add a "Backstage conventions" section to workspaces/ai-integrations/AGENTS.md instructing the agent to prefer upstream @backstage/catalog-model utilities over manual implementations. Specifically:
- When parsing location references (e.g.,
backstage.io/source-locationannotation values), useparseLocationReffrom@backstage/catalog-modelinstead of manualtype:targetstring splitting. - Use the exported constants
ANNOTATION_SOURCE_LOCATION,ANNOTATION_LOCATION, etc. from@backstage/catalog-modelinstead of defining local string constants. - When parsing entity references, use
parseEntityRef/stringifyEntityReffrom@backstage/catalog-model. - Before implementing custom parsing for any Backstage-convention string format, check
@backstage/catalog-modelexports for an existing utility.
Example addition to AGENTS.md:
## Backstage conventions
Prefer upstream utilities from `@backstage/catalog-model` over manual implementations:
- `parseLocationRef` for `type:target` location-ref strings
- `ANNOTATION_SOURCE_LOCATION` / `ANNOTATION_LOCATION` for annotation key constants
- `parseEntityRef` / `stringifyEntityRef` for entity ref strings
Before writing custom parsing for Backstage-convention string formats, check `@backstage/catalog-model` exports.
Validation criteria
On the next 3 code agent PRs in the ai-integrations workspace that involve Backstage location refs or entity refs, the code agent uses upstream utilities from @backstage/catalog-model instead of manual string splitting. Zero instances of manual type:target parsing when parseLocationRef is available.
Generated by retro agent from https://github.com/redhat-developer/rhdh-plugins/pull/3956
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with workspaces/ai-integrations/AGENTS.md and review its existing guidance sections. Add the proposed “Backstage conventions” section covering parseLocationRef, annotation constants, parseEntityRef, stringifyEntityRef, and checking @backstage/catalog-model before custom parsing. Done means the documented guidance addresses the listed utilities and avoids manual type:target parsing when parseLocationRef is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100