@@ -425,7 +425,8 @@ func (s *PostgresStore) syncConfigFromDatabase(ctx context.Context, exampleConfi
425425 if err = os .MkdirAll (filepath .Dir (s .configPath ), 0o700 ); err != nil {
426426 return fmt .Errorf ("postgres store: prepare config directory: %w" , err )
427427 }
428- if err = os .WriteFile (s .configPath , []byte (content ), 0o600 ); err != nil {
428+ normalized := normalizeLineEndings (content )
429+ if err = os .WriteFile (s .configPath , []byte (normalized ), 0o600 ); err != nil {
429430 return fmt .Errorf ("postgres store: write config to spool: %w" , err )
430431 }
431432 }
@@ -528,7 +529,8 @@ func (s *PostgresStore) persistConfig(ctx context.Context, data []byte) error {
528529 ON CONFLICT (id)
529530 DO UPDATE SET content = EXCLUDED.content, updated_at = NOW()
530531 ` , s .fullTableName (s .cfg .ConfigTable ))
531- if _ , err := s .db .ExecContext (ctx , query , defaultConfigKey , string (data )); err != nil {
532+ normalized := normalizeLineEndings (string (data ))
533+ if _ , err := s .db .ExecContext (ctx , query , defaultConfigKey , normalized ); err != nil {
532534 return fmt .Errorf ("postgres store: upsert config: %w" , err )
533535 }
534536 return nil
@@ -652,3 +654,12 @@ func labelFor(metadata map[string]any) string {
652654func normalizeAuthID (id string ) string {
653655 return filepath .ToSlash (filepath .Clean (id ))
654656}
657+
658+ func normalizeLineEndings (s string ) string {
659+ if s == "" {
660+ return s
661+ }
662+ s = strings .ReplaceAll (s , "\r \n " , "\n " )
663+ s = strings .ReplaceAll (s , "\r " , "\n " )
664+ return s
665+ }
0 commit comments