Skip to content

improvement(new-relic): validate integration against NerdGraph docs, surface more entity fields#5443

Merged
waleedlatif1 merged 3 commits into
stagingfrom
validate/new-relic-integration
Jul 6, 2026
Merged

improvement(new-relic): validate integration against NerdGraph docs, surface more entity fields#5443
waleedlatif1 merged 3 commits into
stagingfrom
validate/new-relic-integration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Validated all 4 New Relic tools (nrql_query, search_entities, get_entity, create_deployment_event) and the block against live NerdGraph API docs — auth, region endpoints, request/response shapes, and GraphQL injection handling all confirmed correct
  • Added domain, reporting, alertSeverity, and tags to get_entity/search_entities outputs — stable New Relic Entity schema fields we weren't surfacing. Purely additive, no existing fields changed or renamed
  • Considered NerdGraph's aiIssues/incidents API but skipped it — New Relic marks it "unsafe experimental," requires an opt-in header, and can break without notice

Type of Change

  • Enhancement / validation pass

Testing

Tested manually: typecheck (bun run type-check) and lint (bun run lint) both pass clean. Ran 5 independent audits (one per tool + one for block/registry wiring) against live New Relic docs to confirm alignment and backwards compatibility.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…surface more entity fields

- Audited all 4 New Relic tools (nrql_query, search_entities, get_entity,
  create_deployment_event) plus the block against live NerdGraph API docs;
  request/response shapes, auth, region endpoints, and GraphQL injection
  handling all confirmed correct.
- Added domain, reporting, alertSeverity, and tags to get_entity and
  search_entities outputs — stable Entity schema fields we weren't
  surfacing. Purely additive, no existing fields changed.
- Skipped NerdGraph's aiIssues/incidents API; New Relic marks it "unsafe
  experimental" and requires an opt-in header, not worth the fragility.
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 6, 2026 10:16pm

Request Review

@cursor

cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Additive NerdGraph fields and response mapping only; no auth, request parameters, or existing output fields were removed or renamed.

Overview
Search Entities and Get Entity now return richer NerdGraph entity payloads: domain, reporting, alertSeverity, and tags (in addition to guid, name, and entityType). The tools’ GraphQL queries request those fields via AlertableEntity / AlertableEntityOutline fragments, and responses are shaped through a shared normalizeNewRelicEntity helper and updated NewRelicEntity types.

The New Relic block’s entities and entity output descriptions are updated so workflows document the expanded shape. Existing fields are unchanged; this is additive for consumers that only used the prior three fields.

Reviewed by Cursor Bugbot for commit 7729599. Configure here.

Comment thread apps/sim/tools/new_relic/search_entities.ts
@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends the New Relic integration by surfacing four additional entity fields (domain, reporting, alertSeverity, tags) across the get_entity and search_entities tools, and introduces a shared normalizeNewRelicEntity utility that consistently null-coalesces every field in a single place.

  • Adds NewRelicRawEntity type and normalizeNewRelicEntity to utils.ts, replacing ad-hoc inline normalization with a single reusable function used by both tools.
  • Updates both GraphQL queries to select the new fields (domain, reporting, ... on AlertableEntity/AlertableEntityOutline { alertSeverity }, tags { key values }), and updates output schemas and block descriptions accordingly.
  • The change is purely additive: existing fields (guid, name, entityType) and their semantics are unchanged, and backward compatibility is maintained.

Confidence Score: 5/5

Safe to merge — changes are purely additive, all new fields are null-coalesced, and both tools now share the same normalization path.

The raw-entity passthrough concern raised in the previous review has been fully addressed: search_entities now maps every entity through normalizeNewRelicEntity before returning it, matching what get_entity already did. The new normalizeNewRelicEntity utility handles every nullable field consistently, the inline fragment names (AlertableEntityOutline vs AlertableEntity) are correct for their respective query contexts, and gqlString (backed by JSON.stringify) prevents GraphQL injection in the get_entity query. No existing fields or response shapes were changed.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/tools/new_relic/utils.ts Adds NewRelicRawEntity interface and normalizeNewRelicEntity helper; normalization is thorough with null-coalescing on every field and safe tag iteration.
apps/sim/tools/new_relic/get_entity.ts Adopts NewRelicRawEntity and normalizeNewRelicEntity; guid is correctly injected from params after spread; inline fragment uses the right AlertableEntity (full entity, not outline).
apps/sim/tools/new_relic/search_entities.ts Now correctly maps raw entities through normalizeNewRelicEntity, resolving the previous raw-passthrough issue; uses AlertableEntityOutline correctly for entity search results.
apps/sim/tools/new_relic/types.ts NewRelicEntity extended with domain, reporting, alertSeverity, and tags; new NewRelicEntityTag interface added; all nullable types are consistent with normalization logic.
apps/sim/blocks/blocks/new_relic.ts Block output descriptions updated to reflect new entity fields; change is cosmetic/documentation-only, correctly aligned with tool output schemas.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Caller
    participant Tool as get_entity / search_entities
    participant Utils as utils.ts
    participant NerdGraph as New Relic NerdGraph

    Caller->>Tool: invoke(params)
    Tool->>NerdGraph: POST /graphql (guid/query/cursor, new fields: domain, reporting, alertSeverity, tags)
    NerdGraph-->>Tool: "GraphQLResponse<RawEntity[]>"
    Tool->>Utils: parseNerdGraphResponse()
    Utils-->>Tool: typed payload
    Tool->>Utils: normalizeNewRelicEntity(rawEntity)
    Note over Utils: null-coalesces guid, name, entityType,<br/>domain, reporting, alertSeverity, tags
    Utils-->>Tool: NewRelicEntity (fully normalized)
    Tool-->>Caller: "{ success, output: { entity / entities } }"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Caller
    participant Tool as get_entity / search_entities
    participant Utils as utils.ts
    participant NerdGraph as New Relic NerdGraph

    Caller->>Tool: invoke(params)
    Tool->>NerdGraph: POST /graphql (guid/query/cursor, new fields: domain, reporting, alertSeverity, tags)
    NerdGraph-->>Tool: "GraphQLResponse<RawEntity[]>"
    Tool->>Utils: parseNerdGraphResponse()
    Utils-->>Tool: typed payload
    Tool->>Utils: normalizeNewRelicEntity(rawEntity)
    Note over Utils: null-coalesces guid, name, entityType,<br/>domain, reporting, alertSeverity, tags
    Utils-->>Tool: NewRelicEntity (fully normalized)
    Tool-->>Caller: "{ success, output: { entity / entities } }"
Loading

Reviews (3): Last reviewed commit: "fix(new-relic): gate alertSeverity behin..." | Re-trigger Greptile

…ization

search_entities passed raw NerdGraph entities straight through, so tags/
domain/reporting/alertSeverity could arrive as null/undefined at runtime
despite the non-nullable NewRelicEntity type contract — a .map() on a
null tags array would throw. get_entity already normalized these fields
correctly.

Extracted the normalization into a shared normalizeNewRelicEntity() in
utils.ts and reuse it from both tools, so the two can't drift again.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Fixed — extracted a shared normalizeNewRelicEntity() helper in utils.ts and now use it in both get_entity.ts and search_entities.ts, so entities/tags/scalars are always normalized to the typed null/[] shape regardless of what NerdGraph omits. Pushed in bf5beaa.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit bf5beaa. Configure here.

…fragments

alertSeverity isn't a direct field on New Relic's Entity/EntityOutline
types — it only exists on the AlertableEntity/AlertableEntityOutline
sub-interfaces, and NerdGraph rejects the query outright without the
inline fragment. get_entity.ts (entity(guid), returns Entity) now uses
`... on AlertableEntity { alertSeverity }`; search_entities.ts
(entitySearch, returns EntityOutline) now uses
`... on AlertableEntityOutline { alertSeverity }`. Confirmed against
New Relic's live NerdGraph entities API docs.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Follow-up from an additional independent verification pass (re-checked every field against New Relic's live NerdGraph docs from scratch, including backwards-compat diffing against origin/staging): found that alertSeverity isn't a direct field on the Entity/EntityOutline types — it only exists on the AlertableEntity/AlertableEntityOutline sub-interfaces, so NerdGraph would reject both queries outright without an inline fragment. Fixed in 7729599: get_entity.ts now uses ... on AlertableEntity { alertSeverity }, search_entities.ts uses ... on AlertableEntityOutline { alertSeverity }. Everything else (domain/reporting/tags) is fine as direct fields per the docs.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7729599. Configure here.

@waleedlatif1 waleedlatif1 merged commit 0363451 into staging Jul 6, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the validate/new-relic-integration branch July 6, 2026 22:33
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.

1 participant