Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] [Task] ParameterUtils will throw exception when the input contains '$[xx]' #16914

Closed
3 tasks done
ruanwenjun opened this issue Dec 23, 2024 · 0 comments · Fixed by #16916
Closed
3 tasks done

[Bug] [Task] ParameterUtils will throw exception when the input contains '$[xx]' #16914

ruanwenjun opened this issue Dec 23, 2024 · 0 comments · Fixed by #16916
Assignees
Labels
bug Something isn't working priority:high

Comments

@ruanwenjun
Copy link
Member

ruanwenjun commented Dec 23, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

When the script contains $[str], and str is not a date placeholder, will throw exception, this is unexcepted, the place holder is only used to replace the parameter, if the parameter is not a time place holder, we should skip it rather than throw exception.

What you expected to happen

How to reproduce

public void convertParameterPlaceholders() {
        final String sql = "get_json_object(json_array, '$[abc].pageId')";
        final Map<String, String> paramsMap = new HashMap<>();
        paramsMap.put("key", "value");

        final String result = ParameterUtils.convertParameterPlaceholders(sql, paramsMap);
        System.out.println(result);
    }
java.lang.IllegalArgumentException: Unsupported placeholder expression: abc

	at org.apache.dolphinscheduler.plugin.task.api.parser.TimePlaceholderUtils.calculateTime(TimePlaceholderUtils.java:378)
	at org.apache.dolphinscheduler.plugin.task.api.parser.TimePlaceholderUtils.getPlaceHolderTime(TimePlaceholderUtils.java:346)
	at org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils.dateTemplateParse(ParameterUtils.java:305)
	at org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils.convertParameterPlaceholders(ParameterUtils.java:85)
	at org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtilsTest.convertParameterPlaceholders(ParameterUtilsTest.java:117)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
	at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
	at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
	at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:72)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: java.lang.IllegalArgumentException: Unknown pattern letter: b
	at java.base/java.time.format.DateTimeFormatterBuilder.parsePattern(DateTimeFormatterBuilder.java:1811)
	at java.base/java.time.format.DateTimeFormatterBuilder.appendPattern(DateTimeFormatterBuilder.java:1708)
	at java.base/java.time.format.DateTimeFormatter.ofPattern(DateTimeFormatter.java:564)
	at org.apache.dolphinscheduler.common.utils.DateUtils.format(DateUtils.java:145)
	at org.apache.dolphinscheduler.common.utils.DateUtils.format(DateUtils.java:721)
	at org.apache.dolphinscheduler.plugin.task.api.parser.TimePlaceholderUtils.calculateTime(TimePlaceholderUtils.java:376)
	... 44 more

Anything else

No response

Version

dev

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:high
Projects
None yet
1 participant