Skip to content

Commit

Permalink
Merge branch 'main' into jairus/hyp-2898-warning-on-dynamicmap-usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Jan 8, 2025
2 parents 6813c9e + 387d19e commit b35c816
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- fix: resolve warning in `deserializeRawMap` [#692](https://github.com/hypermodeinc/modus/pull/692)

## 2025-01-07 - CLI 0.16.5

- fix: handle space in user profile path [#696](https://github.com/hypermodeinc/modus/pull/696)

## 2025-01-07 - CLI 0.16.4

No changes. Re-released previous version to fix release issue.
Expand Down
4 changes: 4 additions & 0 deletions cli/src/util/cp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export { exec };
*/
export async function execFileWithExitCode(file: string, args?: string[], options?: cp.ExecFileOptions): Promise<{ stdout: string; stderr: string; exitCode: number }> {
return new Promise((resolve, reject) => {
if (options?.shell) {
file = `"${file}"`;
}

cp.execFile(file, args, options, (error, stdout, stderr) => {
if (typeof stdout !== "string") stdout = stdout.toString();
if (typeof stderr !== "string") stderr = stderr.toString();
Expand Down
3 changes: 2 additions & 1 deletion lib/manifest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ go 1.23.1
toolchain go1.23.4

require (
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1
github.com/tidwall/gjson v1.18.0
github.com/tidwall/jsonc v0.3.2
)

require (
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/text v0.14.0 // indirect
)
8 changes: 6 additions & 2 deletions lib/manifest/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 h1:PKK9DyHxif4LZo+uQSgXNqs0jj5+xZwwfKHgph2lxBw=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/jsonc v0.3.2 h1:ZTKrmejRlAJYdn0kcaFqRAKlxxFIC21pYq8vLa4p2Wc=
Expand All @@ -9,3 +11,5 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
42 changes: 27 additions & 15 deletions lib/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
package manifest

import (
"bytes"
_ "embed"
"encoding/json"
"fmt"
"strings"

"github.com/santhosh-tekuri/jsonschema/v5"
"github.com/santhosh-tekuri/jsonschema/v6"
"github.com/tidwall/gjson"
"github.com/tidwall/jsonc"
)
Expand All @@ -28,6 +30,7 @@ const currentVersion = 3

//go:embed modus_schema.json
var schemaContent string
var schema *jsonschema.Schema

type Manifest struct {
Version int `json:"-"`
Expand All @@ -54,34 +57,43 @@ func (m *Manifest) GetVariables() map[string][]string {
return results
}

func init() {
doc, err := jsonschema.UnmarshalJSON(strings.NewReader(schemaContent))
if err != nil {
panic(fmt.Errorf("failed to parse manifest schema: %w", err))
}

c := jsonschema.NewCompiler()
if err := c.AddResource("modus.json", doc); err != nil {
panic(fmt.Errorf("failed to add manifest schema: %w", err))
}

if sch, err := c.Compile("modus.json"); err != nil {
panic(fmt.Errorf("failed to compile manifest schema: %w", err))
} else {
schema = sch
}
}

func IsCurrentVersion(version int) bool {
return version == currentVersion
}

func ValidateManifest(content []byte) error {

sch, err := jsonschema.CompileString("modus.json", schemaContent)
r := bytes.NewReader(jsonc.ToJSON(content))
doc, err := jsonschema.UnmarshalJSON(r)
if err != nil {
return err
return fmt.Errorf("failed to parse manifest: %w", err)
}

content = jsonc.ToJSONInPlace(content)

var v interface{}
if err := json.Unmarshal(content, &v); err != nil {
return fmt.Errorf("failed to deserialize manifest: %w", err)
}
if err := sch.Validate(v); err != nil {
if err := schema.Validate(doc); err != nil {
return fmt.Errorf("failed to validate manifest: %w", err)
}

return nil
}

func ReadManifest(content []byte) (*Manifest, error) {

content = jsonc.ToJSONInPlace(content)

var manifest Manifest
if err := parseManifestJson(content, &manifest); err != nil {
return nil, fmt.Errorf("failed to parse manifest: %w", err)
Expand All @@ -96,7 +108,7 @@ func parseManifestJson(data []byte, manifest *Manifest) error {
Connections map[string]json.RawMessage `json:"connections"`
Collections map[string]CollectionInfo `json:"collections"`
}
if err := json.Unmarshal(data, &m); err != nil {
if err := json.Unmarshal(jsonc.ToJSON(data), &m); err != nil {
return fmt.Errorf("failed to parse manifest: %w", err)
}

Expand Down
7 changes: 4 additions & 3 deletions runtime/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ require (
github.com/goccy/go-json v0.10.4
github.com/gofrs/flock v0.12.1
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/renameio v1.0.1
github.com/google/renameio/v2 v2.0.0
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.7.2
github.com/jensneuse/abstractlogger v0.0.4
github.com/joho/godotenv v1.5.1
github.com/lestrrat-go/jwx v1.2.30
github.com/lestrrat-go/jwx/v2 v2.1.3
github.com/neo4j/neo4j-go-driver/v5 v5.27.0
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/common v0.61.0
Expand Down Expand Up @@ -95,9 +95,9 @@ require (
github.com/jensneuse/byte-template v0.0.0-20231025215717-69252eb3ed56 // indirect
github.com/kingledion/go-tools v0.6.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.6 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand All @@ -115,6 +115,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/r3labs/sse/v2 v2.10.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/tidwall/jsonc v0.3.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
Expand Down
15 changes: 8 additions & 7 deletions runtime/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg=
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU=
github.com/google/renameio v1.0.1/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg=
github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
Expand Down Expand Up @@ -176,17 +176,16 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A=
github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y=
github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k=
github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E=
github.com/lestrrat-go/httprc v1.0.6 h1:qgmgIRhpvBqexMJjA/PmwSvhNk679oqD1RbovdCGW8k=
github.com/lestrrat-go/httprc v1.0.6/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo=
github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=
github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
github.com/lestrrat-go/jwx v1.2.30 h1:VKIFrmjYn0z2J51iLPadqoHIVLzvWNa1kCsTqNDHYPA=
github.com/lestrrat-go/jwx v1.2.30/go.mod h1:vMxrwFhunGZ3qddmfmEm2+uced8MSI6QFWGTKygjSzQ=
github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
github.com/lestrrat-go/jwx/v2 v2.1.3 h1:Ud4lb2QuxRClYAmRleF50KrbKIoM1TddXgBrneT5/Jo=
github.com/lestrrat-go/jwx/v2 v2.1.3/go.mod h1:q6uFgbgZfEmQrfJfrCo90QcQOcXFMfbI/fO0NqRtvZo=
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4=
Expand Down Expand Up @@ -248,6 +247,8 @@ github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6Ng
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y=
github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
Expand Down
2 changes: 1 addition & 1 deletion runtime/hnsw/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"io"
"os"

"github.com/google/renameio"
"github.com/google/renameio/v2"
)

// errorEncoder is a helper type to encode multiple values
Expand Down
4 changes: 2 additions & 2 deletions runtime/middleware/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/hypermodeinc/modus/runtime/utils"

"github.com/golang-jwt/jwt/v5"
"github.com/lestrrat-go/jwx/jwk"
"github.com/lestrrat-go/jwx/v2/jwk"
)

type jwtClaimsKey string
Expand Down Expand Up @@ -211,7 +211,7 @@ func jwksEndpointsJsonToKeys(ctx context.Context, jwksEndpointsJson string) (map
return nil, err
}

jwkKey, exists := jwks.Get(0)
jwkKey, exists := jwks.Key(0)
if !exists {
return nil, errors.New("No keys found in JWKS for key: " + key)
}
Expand Down

0 comments on commit b35c816

Please sign in to comment.