Skip to content

feat: Add support for string-based namespaces from gRPC clients #9433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

matthewmcneely
Copy link
Member

Description

This PR adds the ability for gRPC clients to create and execute transactions within v25's new string-based namespaces. Managing transactions manually is something common in many repos that use the Dgraph gRPC clients. This new functionality makes upgrading transaction-heavy code (that wants to use string-based namespaces) less cumbersome.

Check out the companion PR in the dgo repo that adds support on the client side along with tests.

Please explain the changes you made here.

Checklist

  • Code compiles correctly and linting passes locally
  • For all code changes, an entry added to the CHANGELOG.md file describing and linking to
    this PR

@github-actions github-actions bot added area/core internal mechanisms go Pull requests that update Go code labels Jun 4, 2025
@matthewmcneely matthewmcneely force-pushed the matthewmcneely/support-namespace-strings-in-txns branch from 358d02c to 2897959 Compare June 4, 2025 17:14
@matthewmcneely matthewmcneely marked this pull request as ready for review June 5, 2025 16:08
@Copilot Copilot AI review requested due to automatic review settings June 5, 2025 16:08
@matthewmcneely matthewmcneely requested a review from a team as a code owner June 5, 2025 16:08
Copy link

@Copilot 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 enables gRPC clients to pass string-based namespaces by extracting a "namespace-str" header, resolving it to a numeric ID, and falling back to the existing JWT namespace logic in QueryNoGrpc.

  • Introduce ExtractNamespaceStr to parse string namespaces from incoming metadata
  • Update QueryNoGrpc to attempt string-to-ID resolution before defaulting to JWT-based namespace

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
x/x.go Added ExtractNamespaceStr to read "namespace-str" from metadata
edgraph/server.go Modified QueryNoGrpc to resolve string namespaces and fallback
Comments suppressed due to low confidence (2)

edgraph/server.go:1199

  • Add unit tests for the new string-based namespace path in QueryNoGrpc to cover both successful resolution and the fallback to JWT namespace.
nsStr, err := x.ExtractNamespaceStr(ctx)

x/x.go:277

  • The metadata key "namespace-str" is hard-coded in multiple places; consider defining it as a package-level constant to avoid typos and ensure consistency.
ns := md.Get("namespace-str")

Copy link

trunk-io bot commented Jun 5, 2025

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

Attach that namespace if found -- will be overwritten if JWL-ACLs namespaces are found
@matthewmcneely matthewmcneely force-pushed the matthewmcneely/support-namespace-strings-in-txns branch from 03f7487 to bedbb28 Compare June 17, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core internal mechanisms go Pull requests that update Go code
Development

Successfully merging this pull request may close these issues.

1 participant