Compare commits

...

5 Commits

Author SHA1 Message Date
ljluestc
cdb2c23d82
Merge 0cebb2da0a9921d5080255df5c18c2699eb58590 into 5f4f9643258dc2a65e684b63f12c8d543c936c67 2026-05-15 03:47:53 +08:00
dependabot[bot]
5f4f964325
chore(deps): bump the actions group across 1 directory with 2 updates (#4640)
Bumps the actions group with 2 updates in the / directory: [codecov/codecov-action](https://github.com/codecov/codecov-action) and [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action).


Updates `codecov/codecov-action` from 5 to 6
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v5...v6)

Updates `aquasecurity/trivy-action` from 0.35.0 to 0.36.0
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](https://github.com/aquasecurity/trivy-action/compare/0.35.0...v0.36.0)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: aquasecurity/trivy-action
  dependency-version: 0.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-09 10:20:32 +08:00
ljluestc
0cebb2da0a fix context copy 2025-03-23 22:40:36 -07:00
ljluestc
e5d837948a fix context error 2025-03-23 22:10:34 -07:00
ljluestc
043b245931 fix context error 2025-03-23 20:49:53 -07:00
4 changed files with 47 additions and 3 deletions

View File

@ -78,6 +78,6 @@ jobs:
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v6
with:
flags: ${{ matrix.os }},go-${{ matrix.go }},${{ matrix.test-tags }}

View File

@ -27,7 +27,7 @@ jobs:
fetch-depth: 0
- name: Run Trivy vulnerability scanner (source code)
uses: aquasecurity/trivy-action@0.35.0
uses: aquasecurity/trivy-action@v0.36.0
with:
scan-type: "fs"
scan-ref: "."
@ -44,7 +44,7 @@ jobs:
sarif_file: "trivy-results.sarif"
- name: Run Trivy scanner (table output for logs)
uses: aquasecurity/trivy-action@0.35.0
uses: aquasecurity/trivy-action@v0.36.0
if: always()
with:
scan-type: "fs"

View File

@ -141,6 +141,15 @@ func (c *Context) Copy() *Context {
cp.Params = make([]Param, len(cParams))
copy(cp.Params, cParams)
cErrors := c.Errors
cp.Errors = make(errorMsgs, len(cErrors))
for i, e := range cErrors {
cp.Errors[i] = &Error{
Err: e.Err,
Type: e.Type,
Meta: e.Meta,
}
}
return &cp
}

View File

@ -688,6 +688,41 @@ func TestContextCopy(t *testing.T) {
assert.Equal(t, cp.fullPath, c.fullPath)
}
func TestContextCopyErrors(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
// Add errors to the original context
c.Error(fmt.Errorf("first error")).SetType(ErrorTypePublic).SetMeta("meta1") // nolint: errcheck
c.Error(fmt.Errorf("second error")).SetType(ErrorTypePrivate).SetMeta(42) // nolint: errcheck
// Copy the context
cp := c.Copy()
// Verify the copied context has the same number of errors
assert.Equal(t, len(c.Errors), len(cp.Errors), "Copied context should have the same number of errors")
// Verify that the slices are distinct (deep copy) by checking contents and ensuring independence
assert.True(t, reflect.DeepEqual(c.Errors, cp.Errors), "Copied errors should have the same content initially")
// Since we cant compare slices with ==, we rely on content equality and test isolation below
// Check each error in the copied context matches the original
for i, origErr := range c.Errors {
copiedErr := cp.Errors[i]
assert.Equal(t, origErr.Err, copiedErr.Err, "Error message should match")
assert.Equal(t, origErr.Type, copiedErr.Type, "Error type should match")
assert.Equal(t, origErr.Meta, copiedErr.Meta, "Error metadata should match")
// Ensure pointers are different (deep copy)
assert.NotSame(t, origErr, copiedErr, "Each error should be a distinct instance")
}
// Modify original context errors and ensure copy remains unchanged
c.Error(fmt.Errorf("third error")) // nolint: errcheck
assert.Equal(t, 2, len(cp.Errors), "Copied context errors should not reflect changes to original")
assert.Equal(t, 3, len(c.Errors), "Original context should have new error")
assert.False(t, reflect.DeepEqual(c.Errors, cp.Errors), "Copied errors should differ after modification")
}
func TestContextHandlerName(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.handlers = HandlersChain{func(c *Context) {}, handlerNameTest}