summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorHÃ¥kon Hallingstad <hakon.hallingstad@gmail.com>2022-04-02 11:57:45 +0200
committerGitHub <noreply@github.com>2022-04-02 11:57:45 +0200
commit7074892f0d55124a9373feae7b18e23855466066 (patch)
tree785f3eb12447a2ee063682f37f702af92e3aec6e /config-model
parentcaa488658d2b5c812e2450f7d91d2a9fb672618f (diff)
Revert "Move verification down"
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java5
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankExpressionBody.java10
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java9
-rw-r--r--config-model/src/main/javacc/IntermediateParser.jj2
-rw-r--r--config-model/src/main/javacc/SDParser.jj2
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java23
6 files changed, 20 insertions, 31 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java b/config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java
index e134b8f53ac..245288c283e 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/DistributableResource.java
@@ -34,6 +34,11 @@ public class DistributableResource {
this.path = path;
this.pathType = type;
}
+ public DistributableResource(String name, ByteBuffer blob) {
+ this.name = name;
+ path = name + ".lz4";
+ pathType = PathType.BLOB;
+ }
//TODO Remove and make path/pathType final
public void setFileName(String fileName) {
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankExpressionBody.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankExpressionBody.java
index 6ba17123fb4..815e4bbf359 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankExpressionBody.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankExpressionBody.java
@@ -6,19 +6,16 @@ import com.yahoo.config.application.api.FileRegistry;
import java.nio.ByteBuffer;
import java.util.Objects;
-import static java.util.Objects.requireNonNull;
-
public class RankExpressionBody extends DistributableResource {
private final ByteBuffer blob;
public RankExpressionBody(String name, ByteBuffer blob) {
- super(name, name + ".lz4", PathType.BLOB);
- this.blob = requireNonNull(blob, "Blob cannot be null");
+ super(name, blob);
+ Objects.requireNonNull(blob, "Blob cannot be null");
+ this.blob = blob;
}
-
public ByteBuffer getBlob() { return blob; }
-
public void validate() {
// Remove once pathType is final
if (getPathType() != PathType.BLOB) {
@@ -29,5 +26,4 @@ public class RankExpressionBody extends DistributableResource {
void register(FileRegistry fileRegistry) {
register(fileRegistry, blob);
}
-
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
index 0f2c1cf9a15..e7b7c92ca2f 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
@@ -5,7 +5,6 @@ import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels;
import com.google.common.collect.ImmutableMap;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.application.api.DeployLogger;
-import com.yahoo.path.Path;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.QueryProfileType;
@@ -883,10 +882,10 @@ public class RankProfile implements Cloneable {
if (!expression.startsWith("file:")) return new StringReader(expression);
String fileName = extractFileName(expression);
- Path.fromString(fileName); // No ".."
- if (fileName.contains("/")) // See ticket 4102122
- throw new IllegalArgumentException("In " + name() + ", " + expName + ", ranking references file '" +
- fileName + "' in a different directory, which is not supported.");
+ File file = new File(fileName);
+ if (!file.isAbsolute() && file.getPath().contains("/")) // See ticket 4102122
+ throw new IllegalArgumentException("In " + name() + ", " + expName + ", ranking references file '" + file +
+ "' in subdirectory, which is not supported.");
return schema.getRankingExpression(fileName);
}
diff --git a/config-model/src/main/javacc/IntermediateParser.jj b/config-model/src/main/javacc/IntermediateParser.jj
index 6119eb5e2ce..8a4798d6f74 100644
--- a/config-model/src/main/javacc/IntermediateParser.jj
+++ b/config-model/src/main/javacc/IntermediateParser.jj
@@ -1773,7 +1773,7 @@ String fileItem() :
String path;
}
{
- (<FILE> <COLON> ( <FILE_PATH> | <STRING> | <IDENTIFIER>) { path = com.yahoo.path.Path.fromString(token.image).getRelative(); } { } (<NL>)*) { return path; }
+ (<FILE> <COLON> ( <FILE_PATH> | <STRING> | <IDENTIFIER>) { path = token.image; } { } (<NL>)*) { return path; }
}
String uriItem() :
{
diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj
index c4542c36779..aeffe6e5c39 100644
--- a/config-model/src/main/javacc/SDParser.jj
+++ b/config-model/src/main/javacc/SDParser.jj
@@ -1907,7 +1907,7 @@ String fileItem() :
String path;
}
{
- (<FILE> <COLON> ( <FILE_PATH> | <STRING> | <IDENTIFIER>) { path = com.yahoo.path.Path.fromString(token.image).getRelative(); } { } (<NL>)*) { return path; }
+ (<FILE> <COLON> ( <FILE_PATH> | <STRING> | <IDENTIFIER>) { path = token.image; } { } (<NL>)*) { return path; }
}
String uriItem() :
{
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java
index c686a813c9f..36a72381156 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java
@@ -62,27 +62,16 @@ public class IntermediateParserTestCase {
@Test
public void multiple_documents_disallowed() throws Exception {
String input = joinLines
- ("schema foo {",
- " document foo {",
- " }",
- " document foo2 {",
- " }",
- "}");
+ ("schema foo {",
+ " document foo {",
+ " }",
+ " document foo2 {",
+ " }",
+ "}");
var e = assertThrows(IllegalArgumentException.class, () -> parseString(input));
assertEquals("schema 'foo' error: already has document 'foo' so cannot add document 'foo2'", e.getMessage());
}
- @Test
- public void backwards_path_is_disallowed() {
- assertThrows("'..' is not allowed in path", IllegalArgumentException.class,
- () -> parseString("schema foo {\n" +
- " constant my_constant_tensor {\n" +
- " file: foo/../bar\n" +
- " type: tensor<float>(x{},y{})\n" +
- " }\n" +
- "}\n"));
- }
-
void checkFileParses(String fileName) throws Exception {
System.err.println("TRY parsing: "+fileName);
var schema = parseFile(fileName);