Skip to content

Commit 8fc6885

Browse files
fix: manifest read
1 parent 4d1bd27 commit 8fc6885

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

internal-api/src/main/java/datadog/trace/api/civisibility/config/BazelMode.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,16 @@ private static boolean isManifestCompatible(Path manifestPath) {
195195
LOGGER.warn("[bazel mode] Manifest file is empty: {}", manifestPath);
196196
return false;
197197
}
198-
// manifest.txt first line should contain the version number
198+
// manifest.txt first line has the shape `version=<int>`
199199
String trimmed = firstLine.trim();
200+
int separatorIdx = trimmed.indexOf('=');
201+
if (separatorIdx < 0 || !"version".equals(trimmed.substring(0, separatorIdx).trim())) {
202+
LOGGER.warn("[bazel mode] Could not parse manifest version from line: '{}'", trimmed);
203+
return false;
204+
}
205+
String versionValue = trimmed.substring(separatorIdx + 1).trim();
200206
try {
201-
int version = Integer.parseInt(trimmed);
207+
int version = Integer.parseInt(versionValue);
202208
if (version == SUPPORTED_MANIFEST_VERSION) {
203209
return true;
204210
}

internal-api/src/test/java/datadog/trace/api/civisibility/config/BazelModeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ private static Config configWith(String manifestRloc, boolean payloadsInFiles) {
158158
return config;
159159
}
160160

161-
private static Path writeManifest(Path dir, String content) throws IOException {
161+
private static Path writeManifest(Path dir, String version) throws IOException {
162162
Files.createDirectories(dir);
163163
Path manifest = dir.resolve("manifest.txt");
164-
Files.write(manifest, content.getBytes(StandardCharsets.UTF_8));
164+
Files.write(manifest, ("version=" + version).getBytes(StandardCharsets.UTF_8));
165165
return manifest;
166166
}
167167

0 commit comments

Comments
 (0)