Skip to content

Fix CCSID 65535 source member CAST to use IBM i Default Job CCSID - #3388

Merged
sebjulliand merged 1 commit into
codefori:masterfrom
bobcozzi:fix-ccsid-65535-source-date-cast
Jul 30, 2026
Merged

Fix CCSID 65535 source member CAST to use IBM i Default Job CCSID#3388
sebjulliand merged 1 commit into
codefori:masterfrom
bobcozzi:fix-ccsid-65535-source-date-cast

Conversation

@bobcozzi

Copy link
Copy Markdown
Contributor

Problem

Users with QCCSID = 65535 (*HEX) and source dates enabled were getting cast(srcdta as varchar(n) CCSID 65535) in the member download SQL. Casting to CCSID 65535 is a no-op and leaves Mapepire with raw EBCDIC bytes.

Root cause

Two bugs in IBMi.ts:

1. Quick-connect bypassed ACTIVE_JOB_INFO resolution
The quick-connect condition allowed a cached jobCcsid = 65535 to be restored directly, skipping the ACTIVE_JOB_INFO lookup on subsequent connections.

2. ACTIVE_JOB_INFO fallback silently kept 65535
The ternary left userJobCcsid at 65535 if DEFAULT_CCSID was falsy, rather than trusting the IBM i-guaranteed value.

IBM i CCSID hierarchy

QCCSID (system value) and Job CCSID can both be 65535. Default Job CCSID (ACTIVE_JOB_INFO.DEFAULT_CCSID) is NEVER 65535 — it is the value IBM i uses when the job CCSID is *HEX.

Changes

  • IBMi.ts: quick-connect now excludes cached 65535 from the fast path; ACTIVE_JOB_INFO result is trusted directly
  • extendedContent.ts: getCcsid() called cleanly, relying on the resolved value

When a source file's SRCDTA column has CCSID 65535 (*HEX) and source
dates are enabled, the SQL query now CASTs srcdta to the correct CCSID.

Two bugs were present in IBMi.ts:

1. Quick-connect restored a cached jobCcsid of 65535 without re-running
   the ACTIVE_JOB_INFO resolution, leaving userJobCcsid permanently at
   65535 across reconnects.

2. The ACTIVE_JOB_INFO fallback used a ternary that silently kept 65535
   if DEFAULT_CCSID was falsy, rather than trusting the value IBM i
   guarantees is never 65535.

IBM i CCSID hierarchy:
  QCCSID (system value) -> can be 65535
  Job CCSID             -> can be 65535
  Default Job CCSID     -> NEVER 65535 (IBM i guarantee)

ACTIVE_JOB_INFO.DEFAULT_CCSID is the authoritative value used when the
job CCSID is *HEX.  extendedContent.ts now calls getCcsid() which,
after the IBMi.ts fixes, always returns this resolved value.
@bobcozzi
bobcozzi temporarily deployed to testing_environment July 29, 2026 20:07 — with GitHub Actions Inactive
@bobcozzi

Copy link
Copy Markdown
Contributor Author

I created a test file for you to confirm that the fix works. once you confirm it does or does not help, you can delete it and revert back to 3.0.12
It is a ZIP file, just unzip it and load it via "Install VSIX from file" via the ... menu on the Extensions Panel.

code-for-ibmi-3.0.13-dev.0.vsix.zip

@sebjulliand sebjulliand left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm wrong, one of these changes is not necessary. It's just replacing a ternary with an if, but the result is the same (but please correct me if I'm wrong).

Forcing a refresh if the cached value is 65535 is great!

Comment thread src/api/IBMi.ts
Comment on lines -682 to +688
this.userJobCcsid = row?.DEFAULT_CCSID ? Number(row.DEFAULT_CCSID) : this.userJobCcsid;
if (row?.DEFAULT_CCSID) {
this.userJobCcsid = Number(row.DEFAULT_CCSID);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem necessary since it does what was done before 😅

@bobcozzi bobcozzi Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is a matter of taste. Yes, I did convert it to an 'if' because I had changed it another way that did not work as I intended, so I deleted that fragment. Leaving it in the shape it is. But if you want it back at a ternary assignment, that's okay but not necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me!

@sebjulliand sebjulliand self-assigned this Jul 30, 2026
@sebjulliand sebjulliand added the bug A confirmed issue when something isn't working as intended label Jul 30, 2026
@sebjulliand
sebjulliand merged commit f93ac0b into codefori:master Jul 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A confirmed issue when something isn't working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants