fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/41170?usp=email )

Change subject: [REST] MetricsList: return 404 on invalid path
......................................................................

[REST] MetricsList: return 404 on invalid path

Change-Id: If5ab039654007ccf3703a2364b767eaa19e43461
Related: SYS#7066
---
M contrib/openapi.yaml
M priv/openapi.json
M src/rest_server.erl
3 files changed, 14 insertions(+), 5 deletions(-)

Approvals:
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/contrib/openapi.yaml b/contrib/openapi.yaml
index e7934b2..a56f876 100644
--- a/contrib/openapi.yaml
+++ b/contrib/openapi.yaml
@@ -31,6 +31,8 @@
             application/json:
               schema:
                 $ref: '#/components/schemas/MetricsList'
+        '404':
+          description: No matching metrics found

   /pfcp/assoc:
     get:
diff --git a/priv/openapi.json b/priv/openapi.json
index 94c0287..5422c03 100644
--- a/priv/openapi.json
+++ b/priv/openapi.json
@@ -46,6 +46,9 @@
                                 }
                             }
                         }
+                    },
+                    "404": {
+                        "description": "No matching metrics found"
                     }
                 }
             }
diff --git a/src/rest_server.erl b/src/rest_server.erl
index 2ea51f6..6e1f892 100644
--- a/src/rest_server.erl
+++ b/src/rest_server.erl
@@ -62,11 +62,15 @@
         << "gauge" >> -> metric_list([gauge]);
         << "all" >> -> metric_list([])
     end,
-    L1 = case proplists:get_value(<< "path" >>, QP) of
-        undefined -> L0;
-        Path -> lists:filter(fun(M) -> metric_filter_path(M, Path) end, L0)
-    end,
-    {200, [], L1}.
+    case proplists:get_value(<< "path" >>, QP) of
+        undefined ->
+            {200, [], L0};
+        Path ->
+            case lists:filter(fun(M) -> metric_filter_path(M, Path) end, L0) of
+                [] -> {404, [], undefined};
+                L1 -> {200, [], L1}
+            end
+    end.


 %% PfcpAssocState :: Get the PFCP association state

--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/41170?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: If5ab039654007ccf3703a2364b767eaa19e43461
Gerrit-Change-Number: 41170
Gerrit-PatchSet: 4
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>

Reply via email to