Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/TDB2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ void TDB2::invalidate_cached_info() {
bool TDB2::get(const std::string& uuid, Task& task) {
auto depmap = replica()->dependency_map();

// Numeric task refs are per-user short IDs. Prefer them over numeric UUID
// prefixes; if no short ID matches, keep the historical UUID-prefix fallback.
// Numeric task refs are per-user short IDs. Only 8-char numeric refs may fall
// back to the historical displayed UUID-prefix form after a short-ID miss.
if (taskref::looksLikeNumericShortId(uuid)) {
auto maybe = replica()->get_task_data_by_ref(uuid);
if (maybe.is_some()) {
Expand All @@ -351,6 +351,10 @@ bool TDB2::get(const std::string& uuid, Task& task) {
apply_depmap(task, *depmap);
return true;
}

if (!taskref::looksLikeHexPrefix(uuid)) {
return false;
}
}

// Tier 1: full-UUID PK fast path.
Expand Down
8 changes: 7 additions & 1 deletion test/short_id.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def setUp(self):
"import -",
input="""[
{"description":"short-id target","entry":"1700000000","status":"pending","uuid":"aaaaaaaa-1111-4111-8111-111111111111"},
{"description":"numeric-prefix target","entry":"1700000000","status":"pending","uuid":"12345678-2222-4222-8222-222222222222"}
{"description":"numeric-prefix target","entry":"1700000000","status":"pending","uuid":"12345678-2222-4222-8222-222222222222"},
{"description":"short-numeric-prefix target","entry":"1700000000","status":"pending","uuid":"42000000-3333-4333-8333-333333333333"}
]""",
)
self._set_short_id(SHORT_ID_UUID, 12345678)
Expand Down Expand Up @@ -90,6 +91,11 @@ def test_uuid_prefix_falls_back_when_no_short_id_matches(self):
code, out, err = self.t("aaaaaaaa export")
self.assertIn('"description":"short-id target"', out)

def test_short_numeric_id_miss_does_not_fallback_to_uuid_prefix(self):
code, out, err = self.t.runError("42 info")
self.assertNotIn("short-numeric-prefix target", out)
self.assertNotIn("short-numeric-prefix target", err)


if __name__ == "__main__":
from simpletap import TAPTestRunner
Expand Down