feat: Entity Panel templating - BED 9017 - #3095
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughKind-info Markdown now renders in graph services for nodes and relationships. Responses expose rendered content and per-entry template errors. Failed rendering preserves the original template. Handlers no longer parse Markdown or aggregate rendering errors. ChangesKind-info Markdown rendering
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant GetNodeByID
participant GetNode
participant renderNodeKindInfos
participant renderMarkdown
Client->>GetNodeByID: request node details
GetNodeByID->>GetNode: load node with kind information
GetNode->>renderNodeKindInfos: render node kind-info records
renderNodeKindInfos->>renderMarkdown: execute Markdown template
renderMarkdown-->>renderNodeKindInfos: rendered content or fallback with error
renderNodeKindInfos-->>GetNode: updated kind-info records
GetNode-->>GetNodeByID: node view data
GetNodeByID-->>Client: Markdown content and template_error
sequenceDiagram
participant Client
participant GetRelationship
participant EndpointNodeLookup
participant renderRelationshipKindInfos
participant renderMarkdown
Client->>GetRelationship: request relationship details
GetRelationship->>EndpointNodeLookup: load source and target nodes
EndpointNodeLookup-->>GetRelationship: endpoint node contexts
GetRelationship->>renderRelationshipKindInfos: render relationship kind-info records
renderRelationshipKindInfos->>renderMarkdown: execute Markdown template
renderMarkdown-->>renderRelationshipKindInfos: rendered content or fallback with error
renderRelationshipKindInfos-->>GetRelationship: updated kind-info records
GetRelationship-->>Client: relationship Markdown and template_error
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
server/graphdb/internal/handlers/relationship_test.go (1)
63-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd response coverage for
template_error.The fixture verifies rendered content but does not verify
TemplateError. Add a case with one failed relationship template and assert that the response preserves its fallback content andtemplate_error.🤖 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 `@server/graphdb/internal/handlers/relationship_test.go` around lines 63 - 70, Add response coverage in the relationship fixture around the existing RenderedMarkdown case by including a relationship with a failed template, its fallback content, and the expected TemplateError value. Assert that the handler response preserves both the fallback rendered content and template_error for that relationship while retaining the existing successful-template coverage.
🤖 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 `@server/graphdb/internal/services/template.go`:
- Around line 171-174: Update both WarnContext calls in the relationship-kind
markdown rendering flow to pass structured slog.String and slog.Any attributes
instead of alternating key-value arguments, preserving the existing info_key and
error values.
- Around line 68-97: Update the unsupportedFns list to use Sprig’s exact randInt
identifier instead of randint, and add a regression test verifying that parsing
a template containing {{ randInt 1 2 }} fails.
---
Nitpick comments:
In `@server/graphdb/internal/handlers/relationship_test.go`:
- Around line 63-70: Add response coverage in the relationship fixture around
the existing RenderedMarkdown case by including a relationship with a failed
template, its fallback content, and the expected TemplateError value. Assert
that the handler response preserves both the fallback rendered content and
template_error for that relationship while retaining the existing
successful-template coverage.
🪄 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: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 4f1d0075-6f30-4b0a-9a4d-24ea061533e5
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (15)
go.modpackages/go/openapi/doc/openapi.jsonpackages/go/openapi/src/paths/graph.nodes.id.yamlpackages/go/openapi/src/schemas/model.kind-info-markdown.yamlserver/graphdb/internal/handlers/node.goserver/graphdb/internal/handlers/node_test.goserver/graphdb/internal/handlers/relationship.goserver/graphdb/internal/handlers/relationship_test.goserver/graphdb/internal/services/node.goserver/graphdb/internal/services/node_test.goserver/graphdb/internal/services/relationship.goserver/graphdb/internal/services/relationship_test.goserver/graphdb/internal/services/services.goserver/graphdb/internal/services/template.goserver/graphdb/internal/services/template_test.go
There was a problem hiding this comment.
Should we include ETAC authorization checks on the source and target nodes associated with the relationship, since the markdown templating can access properties of those nodes?
| if len(relationship.KindInfos) > 0 { | ||
| source, sourceErr := s.GetNode(ctx, relationship.SourceNodeID, false) | ||
| if sourceErr != nil { | ||
| return Relationship{}, fmt.Errorf("fetching relationship source node: %w", sourceErr) |
There was a problem hiding this comment.
since these nodes are only needed for rendering KindInfo, maybe this shouldn't return a hard error? Otherwise if you fetched a relationship with nodes that had been deleted or something, it would fail now with no rel data returned, vs just returning unrendered markdown content with a warning.
Description
spriglibrary for fancy templatinggraphdb/services, following new onion archapi/v2/nodes/{node_id}andapi/v2/relationships/{relationship_id}template_errorfield, such as:Motivation and Context
Resolves BED-9017
We want users to be able to define "dynamic" entity panels. For example, a node entity panel should be able to render dynamic information about that node, and the same is true for a relationship.
We can achieve dynamic entity panels through "templating". This PR uses the
spriglibrary to implement templating on entity panels.How Has This Been Tested?
infoobject like this:Screenshots (optional):
The original ticket provided an example template for a node panel and an edge panel. Here are those dynamic templates rendered in the application:
for a node:

for an edge:

Types of changes
Checklist:
Summary by CodeRabbit
New Features
Documentation
Bug Fixes