Skip to content

Conversation

@shivaji-kharse
Copy link
Contributor

Description

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
  • Tests added for new functionality, or regression tests for bug fixes added as applicable
  • For public APIs, new features, etc., PR on
    docs repo staged and linked here

Instructions

  • The PR title should follow the Conventional Commits
    syntax, leading with fix:, feat:, chore:, ci:, etc.
  • The description should briefly explain what the PR is about. In the case of a bugfix, describe or
    link to the bug.
  • In the checklist section, check the boxes in that are applicable, using [x] syntax.
    • If not applicable, remove the entire line. Only leave the box unchecked if you intend to come
      back and check the box later.
  • Delete the Instructions line and everything below it, to indicate you have read and are
    following these instructions. 🙂

Thank you for your contribution to Dgraph!

@shivaji-kharse shivaji-kharse changed the title Shiva/stream bulk stream bulk Feb 17, 2025
@shivaji-kharse shivaji-kharse marked this pull request as ready for review March 3, 2025 11:53
@shivaji-kharse shivaji-kharse requested a review from a team March 3, 2025 11:53
@github-actions github-actions bot added area/testing Testing related issues area/core internal mechanisms go Pull requests that update Go code labels Mar 3, 2025
if err == nil {
pDir := filepath.Join(basePath, entry.Name(), "p")
if _, err := os.Stat(pDir); err == nil {
groupDirs[uint32(groupID)] = pDir

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types

Incorrect conversion of an integer with architecture-dependent bit size from [strconv.Atoi](1) to a lower bit size type uint32 without an upper bound check.

Copilot Autofix

AI 10 months ago

To fix the problem, we need to ensure that the integer value obtained from strconv.Atoi is within the bounds of the uint32 type before performing the conversion. This can be done by adding a check to ensure the value is non-negative and does not exceed the maximum value of uint32.

The best way to fix this is to use strconv.ParseUint with a bit size of 32, which directly parses the string into a uint32 value, ensuring that the value is within the valid range for uint32. This approach avoids the need for additional bounds checking.

Suggested changeset 1
edgraph/import.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/edgraph/import.go b/edgraph/import.go
--- a/edgraph/import.go
+++ b/edgraph/import.go
@@ -127,3 +127,3 @@
 		if entry.IsDir() {
-			groupID, err := strconv.Atoi(entry.Name())
+			groupID, err := strconv.ParseUint(entry.Name(), 10, 32)
 			if err == nil {
EOF
@@ -127,3 +127,3 @@
if entry.IsDir() {
groupID, err := strconv.Atoi(entry.Name())
groupID, err := strconv.ParseUint(entry.Name(), 10, 32)
if err == nil {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@trunk-io
Copy link

trunk-io bot commented Mar 3, 2025

Static BadgeStatic BadgeStatic BadgeStatic Badge

Failed Test Failure Summary Logs
TestImportApis Error getting p directories: open /home/shiva/workspace/dgraph-work/benchmarks/data/out: no such file or directory Logs ↗︎

View Full Report ↗︎Docs

@shivaji-kharse shivaji-kharse force-pushed the shiva/stream-bulk branch 2 times, most recently from 57ab93a to 2d973be Compare March 10, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core internal mechanisms area/testing Testing related issues go Pull requests that update Go code

Development

Successfully merging this pull request may close these issues.

2 participants