@@ -86,6 +86,28 @@ describe('loadServerConfig', () => {
8686 } ) ;
8787 } ) ;
8888
89+ it ( 'skips project entries with missing or empty roots instead of resolving cwd' , async ( ) => {
90+ const errorSpy = vi . spyOn ( console , 'error' ) ;
91+ const config = JSON . stringify ( {
92+ projects : [ { } , { root : ' ' } , { root : 'valid-root' } ]
93+ } ) ;
94+
95+ await withTempConfig ( config , async ( filePath ) => {
96+ process . env . CODEBASE_CONTEXT_CONFIG_PATH = filePath ;
97+ const result = await loadServerConfig ( ) ;
98+
99+ expect ( result ) . not . toBeNull ( ) ;
100+ expect ( result ! . projects ) . toEqual ( [ { root : path . resolve ( 'valid-root' ) } ] ) ;
101+ expect ( errorSpy ) . toHaveBeenCalledTimes ( 2 ) ;
102+ expect ( errorSpy . mock . calls [ 0 ] [ 0 ] ) . toMatch (
103+ / \[ c o n f i g \] S k i p p i n g p r o j e c t e n t r y w i t h m i s s i n g o r e m p t y r o o t /
104+ ) ;
105+ expect ( errorSpy . mock . calls [ 1 ] [ 0 ] ) . toMatch (
106+ / \[ c o n f i g \] S k i p p i n g p r o j e c t e n t r y w i t h m i s s i n g o r e m p t y r o o t /
107+ ) ;
108+ } ) ;
109+ } ) ;
110+
89111 it ( 'returns valid config for well-formed input with projects and server.port' , async ( ) => {
90112 // Use absolute paths that are valid on all platforms
91113 const projA = path . join ( os . tmpdir ( ) , 'ccc-test-proj-a' ) ;
@@ -147,6 +169,18 @@ describe('loadServerConfig', () => {
147169 } ) ;
148170 } ) ;
149171
172+ it ( 'drops server.port with a warning when value exceeds 65535' , async ( ) => {
173+ const errorSpy = vi . spyOn ( console , 'error' ) ;
174+ const config = JSON . stringify ( { server : { port : 65536 } } ) ;
175+ await withTempConfig ( config , async ( filePath ) => {
176+ process . env . CODEBASE_CONTEXT_CONFIG_PATH = filePath ;
177+ const result = await loadServerConfig ( ) ;
178+ expect ( result ! . server ?. port ) . toBeUndefined ( ) ;
179+ expect ( errorSpy ) . toHaveBeenCalledOnce ( ) ;
180+ expect ( errorSpy . mock . calls [ 0 ] [ 0 ] ) . toMatch ( / \[ c o n f i g \] I g n o r i n g i n v a l i d s e r v e r \. p o r t : 6 5 5 3 6 / ) ;
181+ } ) ;
182+ } ) ;
183+
150184 it ( 'respects CODEBASE_CONTEXT_CONFIG_PATH env var' , async ( ) => {
151185 const config = JSON . stringify ( { server : { port : 4242 } } ) ;
152186 await withTempConfig ( config , async ( filePath ) => {
0 commit comments