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

Default Errors doesn't support 501 status codes #34

Open
fieldju opened this issue Sep 26, 2018 · 1 comment
Open

Default Errors doesn't support 501 status codes #34

fieldju opened this issue Sep 26, 2018 · 1 comment

Comments

@fieldju
Copy link

fieldju commented Sep 26, 2018

This list here https://github.com/Nike-Inc/backstopper/blob/master/backstopper-core/src/main/java/com/nike/backstopper/apierror/projectspecificinfo/ProjectApiErrors.java#L233 doesn't have 501 NOT_IMPLEMENTED in the list.

This stops us from created new new error here: https://github.com/Nike-Inc/cerberus-management-service/blob/master/src/main/java/com/nike/cerberus/error/DefaultApiError.java#L310

We want to add a new error along the lines of this

    /**
     * Call to trigger sms or call challenge for OneLogin is not implemented.
     */
    TRIGGER_CHALLENGE_NOT_IMPLEMENTED(99244, "Call to trigger sms or call challenge for OneLogin is not implemented.", SC_NOT_IMPLEMENTED),
java.lang.AssertionError: getStatusCodePriorityOrder() did not contain HTTP Status Code: 501 for com.nike.cerberus.error.DefaultApiErrorsImpl's ApiError: TRIGGER_CHALLENGE_NOT_IMPLEMENTED
    at com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrorsTestBase.verifyGetStatusCodePriorityOrderMethodContainsAllRelevantCodes(ProjectApiErrorsTestBase.java:111)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
    at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
@nicmunroe
Copy link
Member

@fieldju thanks for the report. We can look at adding some more status codes to the list and trying to find reasonable spots for where they should go in the priority order. We may even decide this kind of situation isn't something that should fail-fast - maybe we should just silently put any unspecified status codes as having lowest priority order?

In the meantime, you can easily work around this by overriding the getStatusCodePriorityOrder() method in your DefaultApiErrorsImpl. It would look something like this:

@Override
public List<Integer> getStatusCodePriorityOrder() {
    // Make a copy of the DEFAULT_STATUS_CODE_PRIORITY_ORDER list.
    List<Integer> statusCodePriorityOrder = new ArrayList<>(DEFAULT_STATUS_CODE_PRIORITY_ORDER);
    // TODO: Put 501 wherever it should go based on what priority you want it to have. For now we'll put it at the end.
    statusCodePriorityOrder.add(501);
    
    return statusCodePriorityOrder;
}

Please read the javadocs for ProjectApiErrors.getStatusCodePriorityOrder() - they'll explain the "what's" and "why's".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants