Commit 3384596
authored
### Rationale for this change
This PR proposes to fix the todo https://github.com/apache/arrow/blob/7ebc88c8fae62ed97bc30865c845c8061132af7e/cpp/src/arrow/status.cc#L131-L134 which would allows a better parsing for line numbers.
I could not find the relevant example to demonstrate within this project but assume that we have a test such as:
(Generated by ChatGPT)
```cpp
TEST(BlockParser, ErrorMessageWithColonsPreserved) {
Status st(StatusCode::Invalid,
"CSV parse error: Row #2: Expected 2 columns, got 3: 12:34:56,key:value,data\n"
"Error details: Time format: 12:34:56, Key: value\n"
"parser_test.cc:940 Parse(parser, csv, &out_size)");
std::string expected_msg =
"Invalid: CSV parse error: Row #2: Expected 2 columns, got 3: 12:34:56,key:value,data\n"
"Error details: Time format: 12:34:56, Key: value";
ASSERT_RAISES_WITH_MESSAGE(Invalid, expected_msg, st);
}
// Test with URL-like data (another common case with colons)
TEST(BlockParser, ErrorMessageWithURLPreserved) {
Status st(StatusCode::Invalid,
"CSV parse error: Row #2: Expected 1 columns, got 2: http://arrow.apache.org:8080/api,data\n"
"URL: http://arrow.apache.org:8080/api\n"
"parser_test.cc:974 Parse(parser, csv, &out_size)");
std::string expected_msg =
"Invalid: CSV parse error: Row #2: Expected 1 columns, got 2: http://arrow.apache.org:8080/api,data\n"
"URL: http://arrow.apache.org:8080/api";
ASSERT_RAISES_WITH_MESSAGE(Invalid, expected_msg, st);
}
```
then it fails.
### What changes are included in this PR?
Fixed `Status::ToStringWithoutContextLines()` to only remove context lines matching the `filename:line` pattern (`:\d+`), preventing legitimate error messages containing colons from being incorrectly stripped.
### Are these changes tested?
Manually tested, and unittests were added, with `cmake .. --preset ninja-debug -DARROW_EXTRA_ERROR_CONTEXT=ON`.
### Are there any user-facing changes?
No, test-only.
* GitHub Issue: #48673
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 08175e5 commit 3384596
2 files changed
+37
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
134 | | - | |
135 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
136 | 154 | | |
137 | 155 | | |
138 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
345 | 362 | | |
0 commit comments