Skip to content

Fix dijkstra via bad alloc on 4.1.0 - #3124

Merged
cvvergara merged 3 commits into
pgRouting:developfrom
cvvergara:fix-dijkstraVia-bad-alloc-dev-1
Jul 28, 2026
Merged

Fix dijkstra via bad alloc on 4.1.0#3124
cvvergara merged 3 commits into
pgRouting:developfrom
cvvergara:fix-dijkstraVia-bad-alloc-dev-1

Conversation

@cvvergara

@cvvergara cvvergara commented Jul 27, 2026

Copy link
Copy Markdown
Member

Changes proposed in this pull request:

@pgRouting/admins

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where pgr_dijkstraVia could throw std::bad_alloc when a specified via node does not exist.
    • Improved handling of routes when no path is available, preventing invalid results.
  • Documentation

    • Added pgRouting 4.0.2 release notes, including a reference to issue 3110 and the documented pgr_dijkstraVia fix.

@cvvergara cvvergara added this to the Release 4.1.0 milestone Jul 27, 2026
@cvvergara
cvvergara requested review from iosefa, robe2 and sanak July 27, 2026 20:00
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

Dijkstra 4.0.2 fix

Layer / File(s) Summary
Dijkstra empty-path handling and regression test
include/dijkstra/dijkstra.hpp, pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg
The 1-to-1 overload handles empty results without accessing paths.front(), with pgTap coverage for missing via vertices.
Version signature and test-version updates
CMakeLists.txt, tools/developer/taptest.sh
Adds version 4.0.2 to old signatures and limits the developer tap test iteration to 4.1.0.
4.0.2 release documentation
NEWS.md, doc/src/release_notes.rst, locale/...
Adds pgRouting 4.0.2 release notes and updated generated localization content for issue 3110.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: Bug Fix, Tests, Documentation, Build

Suggested reviewers: sanak, robe2, iosefa

Poem

A rabbit hops where empty paths were found,
No more bad allocs tumbling underground.
Tests check each missing node with care,
Four-point-oh-two notes bloom everywhere.
“Hop, hop!” says Bun, “the fix is sound!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main bug fix, though the version number is slightly imprecise.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg`:
- Line 8: Update both min_version('4.0.1') guards in the issue-3110 test to
min_version('4.0.2'), including the corresponding skip-message guard, and
correct the “erro” typo in that skip message. Preserve the existing plan and
test behavior.
🪄 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 UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 383f2f61-ffc2-4eb7-be69-7f6767e9ad20

📥 Commits

Reviewing files that changed from the base of the PR and between 313313d and 8b0ba56.

📒 Files selected for processing (8)
  • CMakeLists.txt
  • NEWS.md
  • doc/src/release_notes.rst
  • include/dijkstra/dijkstra.hpp
  • locale/en/LC_MESSAGES/pgrouting_doc_strings.po
  • locale/pot/pgrouting_doc_strings.pot
  • pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg
  • tools/developer/taptest.sh

BEGIN;
SET client_min_messages TO WARNING;

SELECT CASE WHEN min_version('4.0.1') THEN plan(6) ELSE plan(1) END;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== repo files of interest =="
git ls-files | rg '(^|/)(issue-3117\.pg|NEWS\.md|release_notes\.rst|CMakeLists\.txt)$|pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110\.pg' || true

echo
echo "== target file excerpt =="
if [ -f pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg ]; then
  cat -n pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg
fi

echo
echo "== search for issue-3110 and version mentions =="
rg -n "3110|bad alloc|min_version\\('4\\.0\\.[0-9]+" -S . | head -200

Repository: pgRouting/pgrouting

Length of output: 29605


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== repo files of interest =="
git ls-files | rg '(^|/)(NEWS\.md|release_notes\.rst|CMakeLists\.txt)$|pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110\.pg' || true

echo
echo "== target file excerpt =="
if [ -f pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg ]; then
  cat -n pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg
fi

echo
echo "== search for issue-3110 and version mentions =="
rg -n "3110|bad alloc|min_version\\('4\\.0\\.[0-9]+" -S . | head -200

Repository: pgRouting/pgrouting

Length of output: 28836


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== NEWS.md issue-3110 and release header context =="
nl -ba NEWS.md | sed -n '1,110p' | rg -n -C 12 'issue|3110|4\.0\.2|4\.0\.1' || true

echo
echo "== doc/src/release_notes.rst issue-3110 and release header context =="
nl -ba doc/src/release_notes.rst | sed -n '1,120p' | rg -n -C 12 '3110|4\.0\.2|4\.0\.1' || true

echo
echo "== CMakeLists.txt OLD_SIGNATURES version context =="
nl -ba CMakeLists.txt | sed -n '40,70p'

Repository: pgRouting/pgrouting

Length of output: 446


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== NEWS.md issue-3110 and release header context =="
python3 - <<'PY'
from pathlib import Path
p = Path("NEWS.md")
lines = p.read_text().splitlines()
for i, line in enumerate(lines, 1):
    if "3110" in line or "4.0.2 Release" in line or "4.0.1 Release" in line:
        start = max(1, i-8)
        end = min(len(lines), i+8)
        print(f"--- context around line {i} ---")
        for n in range(start, end+1):
            print(f"{n:4}: {lines[n-1]}")
PY

echo
echo "== doc/src/release_notes.rst issue-3110 and release header context =="
python3 - <<'PY'
from pathlib import Path
p = Path("doc/src/release_notes.rst")
lines = p.read_text().splitlines()
for i, line in enumerate(lines, 1):
    if "3110" in line or "4.0.2 Release" in line or "4.0.1 Release" in line:
        start = max(1, i-8)
        end = min(len(lines), i+8)
        print(f"--- context around line {i} ---")
        for n in range(start, end+1):
            print(f"{n:4}: {lines[n-1]}")
PY

echo
echo "== CMakeLists.txt OLD_SIGNATURES version context =="
python3 - <<'PY'
from pathlib import Path
p = Path("CMakeLists.txt")
lines = p.read_text().splitlines()
start, end = 40, 70
print(f"--- lines {start}-{end} ---")
for n in range(start, end+1):
    print(f"{n:4}: {lines[n-1]}")
PY

Repository: pgRouting/pgrouting

Length of output: 5420


Use the release version that actually contains the fix.

issue #3110`` is recorded under the 4.0.2 release notes in `NEWS.md` and `doc/src/release_notes.rst`, with `4.0.2` also listed as a distinct `OLD_SIGNATURES` entry. Update the guards in both `min_version('4.0.1')` occurrences and the skip message to `min_version('4.0.2')`, and fix the “erro” typo.

Also applies to lines 15-17.

🤖 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 `@pgtap/dijkstra/dijkstraVia/edge_cases/issue-3110.pg` at line 8, Update both
min_version('4.0.1') guards in the issue-3110 test to min_version('4.0.2'),
including the corresponding skip-message guard, and correct the “erro” typo in
that skip message. Preserve the existing plan and test behavior.

@cvvergara
cvvergara merged commit df6e9ee into pgRouting:develop Jul 28, 2026
64 checks passed
@cvvergara
cvvergara deleted the fix-dijkstraVia-bad-alloc-dev-1 branch July 28, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants