Skip to content

fix: console.error/warn calls in server (59 occurrences) should go through structured logger - #856

Open
3m1n3nc3 wants to merge 152 commits into
bakeronchain:mainfrom
3m1n3nc3:fix/console-error-warn-calls-in-server-59-occurrences-should-go-through-structured-logger
Open

fix: console.error/warn calls in server (59 occurrences) should go through structured logger#856
3m1n3nc3 wants to merge 152 commits into
bakeronchain:mainfrom
3m1n3nc3:fix/console-error-warn-calls-in-server-59-occurrences-should-go-through-structured-logger

Conversation

@3m1n3nc3

Copy link
Copy Markdown
Contributor

Summary

This PR replaces raw console.error and console.warn usage across the server codebase with the shared structured logger so error reporting goes through a consistent JSON log path.

What changed

  • added a shared server logger with scoped structured output
  • sanitized logged Error objects so production logs omit stack traces
  • migrated server runtime logging from raw console.error and console.warn to the logger
  • migrated server TypeScript maintenance scripts to the same logger
  • added tests covering logger sanitization behavior
  • added an ESLint rule to ban bare console.error in server source and scripts

Why

Raw console calls bypass the server’s structured logging path and make production debugging harder. They also increase the chance of leaking stack traces or inconsistent error payloads. This change centralizes error serialization and makes server-side logging safer and easier to query.

Validation

  • confirmed there are no remaining raw console.error or console.warn calls under server source or server TS scripts
  • added focused logger tests for production-safe error sanitization
  • checked editor diagnostics for touched files

Type of Change

  • Bug fix
  • New feature
  • Smart contract change
  • Documentation
  • Breaking change
  • Other (please describe)

Checklist

Screenshots (if applicable)

Testing

Added focused coverage for the new logging behavior in server/src/tests/logger.test.ts

Additional Notes

“Ayo-Skiller“ and others added 30 commits March 27, 2026 09:26
- Add soroban_sdk import to fungible-allowlist to fix missing panic_handler on wasm32
- Regenerate package-lock.json to fix npm ci lock file mismatch
- Fix floating promise lint errors in DaoPropose, Dashboard, and server/index.ts
- Fix invalid class field syntax in scholarshipTreasury (React hook in class body)
- Fix ReactMarkdown className prop removed in v10 (wrap with div)
- Run prettier across src/ to fix formatting check failures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix merge conflict in upload.routes.ts (missing JSDoc opening comment).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add contractevent to soroban_sdk imports in course_milestone
- Remove unresolved learn_token_client re-export from course_milestone
- Add AlreadyEnrolled/NotEnrolled/DuplicateSubmission variants to Error enum
- Fix export type syntax in src/types/contracts.ts for isolatedModules
- Replace mockContractImports with mockContracts in src/test/setup.ts
- Add missing DonorStats type import in src/hooks/useDonor.ts
- Fix LRNHistoryChart tooltip formatter to accept ValueType | undefined
- Fix Dashboard.tsx progressMap -> getCourseProgress

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Drop non-existent ValueType import; use inferred type in formatter
- Clone env before consuming it in upgrade_timelock_vault::is_upgrade_ready

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contracts:
- scholar_nft: replace broken merge-artifact lib.rs with clean upstream version
- scholar_nft: rewrite test.rs to match actual API (remove non-existent types)
- fungible-allowlist: fix #[contract] placement, drop unused Env import
- course_milestone: remove unused constants/params, add ContractPaused error,
  use correct error variants, add get_milestone_status helper
- upgrade_timelock_vault: fix duplicate create_env, BytesN::random, env.register,
  correct should_panic error strings, fix borrow-after-move
- cargo fmt across all contracts

Frontend:
- LRNHistoryChart: remove non-existent ValueType recharts import
- Admin.tsx: fix floating promise errors (void fetchStats/fetchMilestones)
- Prettier fixes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… unit tests

- Add verify_milestone() function for admin milestone verification with LRN token minting
- Add reject_milestone() function for admin milestone rejection
- Add get_milestone_status() function to query milestone states
- Create learn_token_client module for LRN token integration
- Add comprehensive unit tests covering all functions:
  - enroll() happy path, duplicate enroll, unknown course scenarios
  - verify_milestone() happy path, non-admin caller, already verified cases
  - reject_milestone() happy path, wrong state, non-admin scenarios
  - get_milestone_status() all state transitions
  - LRN minting integration tests
  - Pause functionality tests for all operations
- Update error handling with new error variants (NotEnrolled, DuplicateSubmission, InvalidState, ContractPaused)
- Fix existing functions to use correct error variants
- Update initialize function to store learn token contract address

Closes bakeronchain#230
- Trigger on pull_request targeting main
- Run typecheck, lint, vitest, and build steps
- Upload dist artifact on success
…scarded errors from courseImilestore,scholar_nft,fungible_allowlist to allow cargo to build successfully
- Document LRN as soulbound reputation score with supply model
- Document GOV as transferable voting token with mint/burn model
- Add flywheel diagram showing LRN → GOV → donor → proposal cycle
- Honest accounting of V1 centralization and V2 roadmap
- Flag GOV burn mechanic as open design question

Closes bakeronchain#139
- Poll comments every 15s (configurable via VITE_COMMENT_POLL_MS)
- Add "Last updated" timestamp for user feedback
- Silent refresh prevents UI flickering during background polls
- Clean up interval on unmount to prevent memory leaks
- Add localized string for last updated timestamp
Poll comments every 15s (configurable via VITE_COMMENT_POLL_MS)
- Add "Last updated" timestamp for user feedback
- Silent refresh prevents UI flickering during background polls
- Clean up interval on unmount to prevent memory leaks
- Add localized string for last updated timestamp
closes: bakeronchain#435
- Add server/src/db/migrations/ with 005_governance_and_comments.sql
  (comments, comment_votes, proposals, scholar_balances)
- Fix dollar-quote syntax bug in 003_course_content_schema.sql ($ -> \$\$)
- Rewrite scripts/migrate.ts: supports 'up' and 'down' (rollback) commands,
  typed with PoolClient, tabs formatting to match project style
- Strip all CREATE TABLE / DDL from db/index.ts; initDb() now only verifies
  connection and confirms schema_migrations table exists, exits with clear
  error if migrations haven't been run
- Add migrate and migrate:rollback scripts to server/package.json
- Add .github/workflows/server-ci.yml: spins up Postgres 16, runs migrations,
  then runs jest tests on every push/PR touching server/
- Regenerate package-lock.json to fix missing @noble/hashes@2.0.1 (npm ci failure)
- Fix xdr.ScVal.scvU64 call — wrap tokenId with new xdr.Uint64() (TS2345)
- Add NftRow type to getScholarCredentials to fix implicit any on row (TS7006)
- Add non-null assertion on JWT_SECRET in admin.middleware (TS2769)
- Add JWT_SECRET fallback to course-admin.middleware when JWT_PUBLIC_KEY absent
- Set process.env.JWT_SECRET in courses-api.test so requireCourseAdmin can verify tokens
- Fix upload.test and comments.test — switch from removed uploadRouter/commentsRouter
  exports to createUploadRouter/createCommentsRouter with inline test JwtService

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Anuoluwapo25

Copy link
Copy Markdown
Contributor

try force async.... pull from upsteam @3m1n3nc3

…n-calls-in-server-59-occurrences-should-go-through-structured-logger
@3m1n3nc3

Copy link
Copy Markdown
Contributor Author

try force async.... pull from upsteam @3m1n3nc3

I've done that

@Anuoluwapo25

Copy link
Copy Markdown
Contributor

i still can't merge and i can't fix from my end...you can ask AI for assistance

Anuoluwapo25 and others added 6 commits April 29, 2026 21:56
feat: complete i18n translations and localization for French language…
…prep

feat: prepare smart contracts for formal security audit
…-cache

feat: Add Redis RPC cache layer to reduce Stellar RPC calls per page load
…n-calls-in-server-59-occurrences-should-go-through-structured-logger
@3m1n3nc3

Copy link
Copy Markdown
Contributor Author

i still can't merge and i can't fix from my end...you can ask AI for assistance

I've resolved the remaining conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: console.error/warn calls in server (59 occurrences) should go through structured logger