Skip to content

Conversation

@angles-n-daemons
Copy link
Contributor

@angles-n-daemons angles-n-daemons commented Sep 30, 2025

Previously, we would query crdb_internal.node_build_info table to get
a cluster's version info. Starting at 26.1, we'll be blocking access to
crdb_internal tables, as they're considered part of the "unsafe
internals". To mitigate this issue before release, we'll use instead
SHOW crdb_version to collect version information about the cluster.

Fixes: #154660
Release note: none

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link

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 fixes an issue with ORM examples by modifying how version strings are extracted from CockroachDB. The SHOW crdb_version query returns a fuller string (e.g., "CockroachDB v21.1.0") rather than just the version, requiring the Parse function to extract the version substring instead of requiring an exact match.

Key changes:

  • Modified version.Parse() to extract version substrings from larger strings using FindString instead of requiring exact matches
  • Updated SQL query in tests from crdb_internal.node_build_info to SHOW crdb_version
  • Reformatted documentation comments to follow Go conventions

Reviewed Changes

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

File Description
version/version.go Modified Parse function to extract version substrings, removed regex anchors, and improved doc formatting
testing/main_test.go Changed database version query to use SHOW crdb_version instead of internal table lookup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// version (as per https://semver.org/spec/v2.0.0.html) in the format:
// "vMINOR.MAJOR.PATCH[-PRERELEASE][+METADATA]".
//
// "vMINOR.MAJOR.PATCH[-PRERELEASE][+METADATA]".
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

The version format in the documentation is incorrect. It should be "vMAJOR.MINOR.PATCH" not "vMINOR.MAJOR.PATCH". The order of MAJOR and MINOR is swapped.

Suggested change
// "vMINOR.MAJOR.PATCH[-PRERELEASE][+METADATA]".
// "vMAJOR.MINOR.PATCH[-PRERELEASE][+METADATA]".

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

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

This seems like a good suggestion. This pre-existed your change, but since you are changing things close by, it makes sense to fix with your change.

@angles-n-daemons angles-n-daemons force-pushed the fix-allow-unsafe-internals-check branch 4 times, most recently from a5c46ae to fa9f616 Compare November 18, 2025 15:40
@angles-n-daemons angles-n-daemons changed the title see if I can fix the example orms issue version: update version check to use safe introspection tool Nov 18, 2025
@angles-n-daemons angles-n-daemons force-pushed the fix-allow-unsafe-internals-check branch 2 times, most recently from a7ab5a5 to b5ed13e Compare November 18, 2025 15:48
Copy link

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

Looks good. We should probably resolve the linter error, although maybe in a separate PR as it seems unrelated to your change and a problem with the Go toolchain used in the CI. There aren't many changes to this repo (the last CI run was from Feb 2024), which is why it's only be noticed now.
:lgtm:

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion

// version (as per https://semver.org/spec/v2.0.0.html) in the format:
// "vMINOR.MAJOR.PATCH[-PRERELEASE][+METADATA]".
//
// "vMINOR.MAJOR.PATCH[-PRERELEASE][+METADATA]".

Choose a reason for hiding this comment

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

This seems like a good suggestion. This pre-existed your change, but since you are changing things close by, it makes sense to fix with your change.

@angles-n-daemons angles-n-daemons force-pushed the fix-allow-unsafe-internals-check branch from b5ed13e to f434efa Compare November 19, 2025 18:33
@angles-n-daemons
Copy link
Contributor Author

Got it, I'll make that change, I'll also see if I can figure out how to fix the linting issue, but time box it.

Previously, we would query `crdb_internal.node_build_info` table to get
a cluster's version info. Starting at 26.1, we'll be blocking access to
crdb_internal tables, as they're considered part of the "unsafe
internals". To mitigate this issue before release, we'll use instead
`SHOW crdb_version` to collect version information about the cluster.

Fixes: #154660
Release note: none
@angles-n-daemons angles-n-daemons force-pushed the fix-allow-unsafe-internals-check branch from f434efa to 600b4c0 Compare November 19, 2025 18:36
@angles-n-daemons angles-n-daemons merged commit 4422aff into cockroachdb:master Nov 19, 2025
2 of 3 checks passed
@angles-n-daemons angles-n-daemons deleted the fix-allow-unsafe-internals-check branch November 19, 2025 19:46
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.

3 participants