Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3c2f3d6

Browse files
authored
chore: remove dbmem (#18803)
Remove the in-memory database. Addresses#15109.
1 parent1319ae2 commit3c2f3d6

File tree

33 files changed

+143
-15000
lines changed

33 files changed

+143
-15000
lines changed

‎.claude/docs/DATABASE.md

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,6 @@ If adding fields to auditable types:
5858
-`ActionSecret`: Field contains sensitive data
5959
3. Run`make gen` to verify no audit errors
6060

61-
##In-Memory Database (dbmem) Updates
62-
63-
###Critical Requirements
64-
65-
When adding new fields to database structs:
66-
67-
-**CRITICAL**: Update`coderd/database/dbmem/dbmem.go` in-memory implementations
68-
- The`Insert*` functions must include ALL new fields, not just basic ones
69-
- Common issue: Tests pass with real database but fail with in-memory database due to missing field mappings
70-
- Always verify in-memory database functions match the real database schema after migrations
71-
72-
###Example Pattern
73-
74-
```go
75-
// In dbmem.go - ensure ALL fields are included
76-
code:= database.OAuth2ProviderAppCode{
77-
ID: arg.ID,
78-
CreatedAt: arg.CreatedAt,
79-
// ... existing fields ...
80-
ResourceUri: arg.ResourceUri,// New field
81-
CodeChallenge: arg.CodeChallenge,// New field
82-
CodeChallengeMethod: arg.CodeChallengeMethod,// New field
83-
}
84-
```
85-
8661
##Database Architecture
8762

8863
###Core Components
@@ -116,7 +91,6 @@ roles, err := db.GetAuthorizationUserRoles(dbauthz.AsSystemRestricted(ctx), user
11691

11792
1.**Nullable field errors**: Use`sql.Null*` types consistently
11893
2.**Missing audit entries**: Update`enterprise/audit/table.go`
119-
3.**dbmem inconsistencies**: Ensure in-memory implementations match schema
12094

12195
###Query Issues
12296

@@ -139,19 +113,6 @@ func TestDatabaseFunction(t *testing.T) {
139113
}
140114
```
141115

142-
###In-Memory Testing
143-
144-
```go
145-
funcTestInMemoryDatabase(t *testing.T) {
146-
db:= dbmem.New()
147-
148-
// Test with in-memory database
149-
result,err:= db.GetSomething(ctx, param)
150-
require.NoError(t, err)
151-
require.Equal(t, expected, result)
152-
}
153-
```
154-
155116
##Best Practices
156117

157118
###Schema Design

‎.claude/docs/OAUTH2.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,13 @@ Always run the full test suite after OAuth2 changes:
112112
##Common OAuth2 Issues
113113

114114
1.**OAuth2 endpoints returning wrong error format** - Ensure OAuth2 endpoints return RFC 6749 compliant errors
115-
2.**OAuth2 tests failing but scripts working** - Check in-memory database implementations in`dbmem.go`
116-
3.**Resource indicator validation failing** - Ensure database stores and retrieves resource parameters correctly
117-
4.**PKCE tests failing** - Verify both authorization code storage and token exchange handle PKCE fields
118-
5.**RFC compliance failures** - Verify against actual RFC specifications, not assumptions
119-
6.**Authorization context errors in public endpoints** - Use`dbauthz.AsSystemRestricted(ctx)` pattern
120-
7.**Default value mismatches** - Ensure database migrations match application code defaults
121-
8.**Bearer token authentication issues** - Check token extraction precedence and format validation
122-
9.**URI validation failures** - Support both standard schemes and custom schemes per protocol requirements
115+
2.**Resource indicator validation failing** - Ensure database stores and retrieves resource parameters correctly
116+
3.**PKCE tests failing** - Verify both authorization code storage and token exchange handle PKCE fields
117+
4.**RFC compliance failures** - Verify against actual RFC specifications, not assumptions
118+
5.**Authorization context errors in public endpoints** - Use`dbauthz.AsSystemRestricted(ctx)` pattern
119+
6.**Default value mismatches** - Ensure database migrations match application code defaults
120+
7.**Bearer token authentication issues** - Check token extraction precedence and format validation
121+
8.**URI validation failures** - Support both standard schemes and custom schemes per protocol requirements
123122

124123
##Authorization Context Patterns
125124

‎.claude/docs/TESTING.md

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,6 @@
3939
2.**Verify information disclosure protections**
4040
3.**Test token security and proper invalidation**
4141

42-
##Database Testing
43-
44-
###In-Memory Database Testing
45-
46-
When adding new database fields:
47-
48-
-**CRITICAL**: Update`coderd/database/dbmem/dbmem.go` in-memory implementations
49-
- The`Insert*` functions must include ALL new fields, not just basic ones
50-
- Common issue: Tests pass with real database but fail with in-memory database due to missing field mappings
51-
- Always verify in-memory database functions match the real database schema after migrations
52-
53-
Example pattern:
54-
55-
```go
56-
// In dbmem.go - ensure ALL fields are included
57-
code:= database.OAuth2ProviderAppCode{
58-
ID: arg.ID,
59-
CreatedAt: arg.CreatedAt,
60-
// ... existing fields ...
61-
ResourceUri: arg.ResourceUri,// New field
62-
CodeChallenge: arg.CodeChallenge,// New field
63-
CodeChallengeMethod: arg.CodeChallengeMethod,// New field
64-
}
65-
```
66-
6742
##Test Organization
6843

6944
###Test File Structure
@@ -107,15 +82,13 @@ coderd/
10782

10883
###Database-Related
10984

110-
1.**Tests passing locally but failing in CI** - Check if`dbmem` implementation needs updating
111-
2.**SQL type errors** - Use`sql.Null*` types for nullable fields
112-
3.**Race conditions in tests** - Use unique identifiers instead of hardcoded names
85+
1.**SQL type errors** - Use`sql.Null*` types for nullable fields
86+
2.**Race conditions in tests** - Use unique identifiers instead of hardcoded names
11387

11488
###OAuth2 Testing
11589

116-
1.**OAuth2 tests failing but scripts working** - Check in-memory database implementations in`dbmem.go`
117-
2.**PKCE tests failing** - Verify both authorization code storage and token exchange handle PKCE fields
118-
3.**Resource indicator validation failing** - Ensure database stores and retrieves resource parameters correctly
90+
1.**PKCE tests failing** - Verify both authorization code storage and token exchange handle PKCE fields
91+
2.**Resource indicator validation failing** - Ensure database stores and retrieves resource parameters correctly
11992

12093
###General Issues
12194

‎.claude/docs/TROUBLESHOOTING.md

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,59 +21,50 @@
2121
}
2222
```
2323

24-
3. **Tests passing locally but failing inCI**
25-
- **Solution**:Checkif`dbmem` implementation needs updating
26-
-Update`coderd/database/dbmem/dbmem.go`forInsert/Update methods
27-
-Missing fields in dbmem can cause tests to fail evenif main implementation is correct
28-
2924
###TestingIssues
3025

31-
4. **"package should be X_test"**
26+
3. **"package should be X_test"**
3227
- **Solution**:Use`package_test` namingfor test files
3328
-Example:`identityprovider_test`for black-box testing
3429

35-
5. **Race conditions in tests**
30+
4. **Race conditions in tests**
3631
- **Solution**:Use unique identifiers instead of hardcoded names
3732
-Example:`fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano())`
3833
-Never use hardcoded names in concurrent tests
3934

40-
6. **Missing newlines**
35+
5. **Missing newlines**
4136
- **Solution**:Ensure files end with newline character
4237
-Most editors can be configured to add this automatically
4338

4439
###OAuth2Issues
4540

46-
7. **OAuth2 endpoints returning wrongerror format**
41+
6. **OAuth2 endpoints returning wrongerror format**
4742
- **Solution**:EnsureOAuth2 endpointsreturnRFC6749 compliant errors
4843
-Use standarderror codes:`invalid_client`,`invalid_grant`,`invalid_request`
4944
-Format:`{"error": "code", "error_description": "details"}`
5045

51-
8. **OAuth2 tests failing but scripts working**
52-
- **Solution**:Check in-memory database implementations in`dbmem.go`
53-
-Ensure allOAuth2 fields are properly copied inInsert/Update methods
54-
55-
9. **Resource indicator validation failing**
46+
7. **Resource indicator validation failing**
5647
- **Solution**:Ensure database stores and retrieves resource parameters correctly
5748
-Check both authorization code storage and token exchange handling
5849

59-
10. **PKCE tests failing**
50+
8. **PKCE tests failing**
6051
- **Solution**:Verify both authorization code storage and token exchange handlePKCE fields
6152
-Check`CodeChallenge` and`CodeChallengeMethod` field handling
6253

6354
###RFCComplianceIssues
6455

65-
11. **RFC compliance failures**
56+
9. **RFC compliance failures**
6657
- **Solution**:Verify against actualRFC specifications, not assumptions
6758
-UseWebFetch tool to get currentRFC contentfor compliance verification
6859
-Read the actualRFC specifications before implementation
6960

70-
12. **Default value mismatches**
61+
10. **Default value mismatches**
7162
- **Solution**:Ensure database migrations match application code defaults
7263
-Example:RFC7591 specifies`client_secret_basic` asdefault, not`client_secret_post`
7364

7465
###AuthorizationIssues
7566

76-
13. **Authorization context errors in public endpoints**
67+
11. **Authorization context errors in public endpoints**
7768
- **Solution**:Use`dbauthz.AsSystemRestricted(ctx)` pattern
7869
-Example:
7970

@@ -84,17 +75,17 @@
8475

8576
###AuthenticationIssues
8677

87-
14. **Bearer token authentication issues**
78+
12. **Bearer token authentication issues**
8879
- **Solution**:Check token extraction precedence and format validation
8980
-Ensure properRFC6750BearerTokenSupport implementation
9081

91-
15. **URI validation failures**
82+
13. **URI validation failures**
9283
- **Solution**:Support both standard schemes and custom schemes per protocol requirements
9384
-NativeOAuth2 apps may use custom schemes
9485

9586
###GeneralDevelopmentIssues
9687

97-
16. **Log message formatting errors**
88+
14. **Log message formatting errors**
9889
- **Solution**:Use lowercase, descriptive messages without special characters
9990
-FollowGo logging conventions
10091

‎.claude/docs/WORKFLOWS.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@
8181
- Add each new field with appropriate action (ActionTrack, ActionIgnore, ActionSecret)
8282
- Run`make gen` to verify no audit errors
8383

84-
6.**In-memory database (dbmem) updates**:
85-
- When adding new fields to database structs, ensure`dbmem` implementation copies all fields
86-
- Check`coderd/database/dbmem/dbmem.go` for Insert/Update methods
87-
- Missing fields in dbmem can cause tests to fail even if main implementation is correct
88-
8984
###Database Generation Process
9085

9186
1. Modify SQL files in`coderd/database/queries/`
@@ -164,9 +159,8 @@
164159

165160
1.**Development server won't start** - Use`./scripts/develop.sh` instead of manual commands
166161
2.**Database migration errors** - Check migration file format and use helper scripts
167-
3.**Test failures after database changes** - Update`dbmem` implementations
168-
4.**Audit table errors** - Update`enterprise/audit/table.go` with new fields
169-
5.**OAuth2 compliance issues** - Ensure RFC-compliant error responses
162+
3.**Audit table errors** - Update`enterprise/audit/table.go` with new fields
163+
4.**OAuth2 compliance issues** - Ensure RFC-compliant error responses
170164

171165
###Debug Commands
172166

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp